+static void
+iavf_stat_update_48(uint64_t *offset, uint64_t *stat)
+{
+ if (*stat >= *offset)
+ *stat = *stat - *offset;
+ else
+ *stat = (uint64_t)((*stat +
+ ((uint64_t)1 << IAVF_48_BIT_WIDTH)) - *offset);
+
+ *stat &= IAVF_48_BIT_MASK;
+}
+
+static void
+iavf_stat_update_32(uint64_t *offset, uint64_t *stat)
+{
+ if (*stat >= *offset)
+ *stat = (uint64_t)(*stat - *offset);
+ else
+ *stat = (uint64_t)((*stat +
+ ((uint64_t)1 << IAVF_32_BIT_WIDTH)) - *offset);
+}
+
+static void
+iavf_update_stats(struct iavf_vsi *vsi, struct virtchnl_eth_stats *nes)
+{
+ struct virtchnl_eth_stats *oes = &vsi->eth_stats_offset;
+
+ iavf_stat_update_48(&oes->rx_bytes, &nes->rx_bytes);
+ iavf_stat_update_48(&oes->rx_unicast, &nes->rx_unicast);
+ iavf_stat_update_48(&oes->rx_multicast, &nes->rx_multicast);
+ iavf_stat_update_48(&oes->rx_broadcast, &nes->rx_broadcast);
+ iavf_stat_update_32(&oes->rx_discards, &nes->rx_discards);
+ iavf_stat_update_48(&oes->tx_bytes, &nes->tx_bytes);
+ iavf_stat_update_48(&oes->tx_unicast, &nes->tx_unicast);
+ iavf_stat_update_48(&oes->tx_multicast, &nes->tx_multicast);
+ iavf_stat_update_48(&oes->tx_broadcast, &nes->tx_broadcast);
+ iavf_stat_update_32(&oes->tx_errors, &nes->tx_errors);
+ iavf_stat_update_32(&oes->tx_discards, &nes->tx_discards);
+}
+