raw/ioat: support xstats reset
authorCiara Power <ciara.power@intel.com>
Tue, 29 Oct 2019 13:41:47 +0000 (13:41 +0000)
committerDavid Marchand <david.marchand@redhat.com>
Wed, 30 Oct 2019 09:07:44 +0000 (10:07 +0100)
The rawdev xstats_reset function is now enabled.  It is called when the
ioat autotest completes, to reset all xstat values after they have been
modified during testing.

Signed-off-by: Ciara Power <ciara.power@intel.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
drivers/raw/ioat/ioat_rawdev.c
drivers/raw/ioat/ioat_rawdev_test.c

index 7270ad7..af8414b 100644 (file)
@@ -161,6 +161,43 @@ ioat_xstats_get_names(const struct rte_rawdev *dev,
        return RTE_DIM(xstat_names);
 }
 
+static int
+ioat_xstats_reset(struct rte_rawdev *dev, const uint32_t *ids, uint32_t nb_ids)
+{
+       struct rte_ioat_rawdev *ioat = dev->dev_private;
+       unsigned int i;
+
+       if (!ids) {
+               ioat->enqueue_failed = 0;
+               ioat->enqueued = 0;
+               ioat->started = 0;
+               ioat->completed = 0;
+               return 0;
+       }
+
+       for (i = 0; i < nb_ids; i++) {
+               switch (ids[i]) {
+               case 0:
+                       ioat->enqueue_failed = 0;
+                       break;
+               case 1:
+                       ioat->enqueued = 0;
+                       break;
+               case 2:
+                       ioat->started = 0;
+                       break;
+               case 3:
+                       ioat->completed = 0;
+                       break;
+               default:
+                       IOAT_PMD_WARN("Invalid xstat id - cannot reset value");
+                       break;
+               }
+       }
+
+       return 0;
+}
+
 extern int ioat_rawdev_test(uint16_t dev_id);
 
 static int
@@ -173,6 +210,7 @@ ioat_rawdev_create(const char *name, struct rte_pci_device *dev)
                        .dev_info_get = ioat_dev_info_get,
                        .xstats_get = ioat_xstats_get,
                        .xstats_get_names = ioat_xstats_get_names,
+                       .xstats_reset = ioat_xstats_reset,
                        .dev_selftest = ioat_rawdev_test,
        };
 
index e99f97e..c37351a 100644 (file)
@@ -223,6 +223,11 @@ ioat_rawdev_test(uint16_t dev_id)
        printf("\n");
 
        rte_rawdev_stop(dev_id);
+       if (rte_rawdev_xstats_reset(dev_id, NULL, 0) != 0) {
+               printf("Error resetting xstat values\n");
+               goto err;
+       }
+
        rte_mempool_free(pool);
        free(snames);
        free(stats);
@@ -231,6 +236,7 @@ ioat_rawdev_test(uint16_t dev_id)
 
 err:
        rte_rawdev_stop(dev_id);
+       rte_rawdev_xstats_reset(dev_id, NULL, 0);
        rte_mempool_free(pool);
        free(snames);
        free(stats);