ethdev: add return value to stats get dev op
[dpdk.git] / drivers / net / failsafe / failsafe_ops.c
index ff9ad15..d360965 100644 (file)
@@ -582,13 +582,25 @@ fs_link_update(struct rte_eth_dev *dev,
        return -1;
 }
 
-static void
+static int
 fs_stats_get(struct rte_eth_dev *dev,
             struct rte_eth_stats *stats)
 {
-       if (TX_SUBDEV(dev) == NULL)
-               return;
-       rte_eth_stats_get(PORT_ID(TX_SUBDEV(dev)), stats);
+       struct sub_device *sdev;
+       uint8_t i;
+       int ret;
+
+       rte_memcpy(stats, &PRIV(dev)->stats_accumulator, sizeof(*stats));
+       FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
+               ret = rte_eth_stats_get(PORT_ID(sdev), &sdev->stats_snapshot);
+               if (ret) {
+                       ERROR("Operation rte_eth_stats_get failed for sub_device %d with error %d",
+                                 i, ret);
+                       return ret;
+               }
+               failsafe_stats_increment(stats, &sdev->stats_snapshot);
+       }
+       return 0;
 }
 
 static void
@@ -597,8 +609,11 @@ fs_stats_reset(struct rte_eth_dev *dev)
        struct sub_device *sdev;
        uint8_t i;
 
-       FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
+       FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
                rte_eth_stats_reset(PORT_ID(sdev));
+               memset(&sdev->stats_snapshot, 0, sizeof(struct rte_eth_stats));
+       }
+       memset(&PRIV(dev)->stats_accumulator, 0, sizeof(struct rte_eth_stats));
 }
 
 /**