raw/ioat: move xstats functions to common file
authorBruce Richardson <bruce.richardson@intel.com>
Thu, 8 Oct 2020 09:51:30 +0000 (10:51 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 8 Oct 2020 12:33:20 +0000 (14:33 +0200)
The xstats functions can be used by all ioat devices so move them from the
ioat_rawdev.c file to ioat_common.c, and add the function prototypes to the
internal header file.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Kevin Laatz <kevin.laatz@intel.com>
Acked-by: Radu Nicolau <radu.nicolau@intel.com>
drivers/raw/ioat/ioat_common.c
drivers/raw/ioat/ioat_private.h
drivers/raw/ioat/ioat_rawdev.c

index b5cea2f..142e171 100644 (file)
@@ -5,9 +5,68 @@
 #include <rte_rawdev_pmd.h>
 #include <rte_memzone.h>
 #include <rte_common.h>
+#include <rte_string_fns.h>
 
 #include "ioat_private.h"
 
+static const char * const xstat_names[] = {
+               "failed_enqueues", "successful_enqueues",
+               "copies_started", "copies_completed"
+};
+
+int
+ioat_xstats_get(const struct rte_rawdev *dev, const unsigned int ids[],
+               uint64_t values[], unsigned int n)
+{
+       const struct rte_ioat_rawdev *ioat = dev->dev_private;
+       const uint64_t *stats = (const void *)&ioat->xstats;
+       unsigned int i;
+
+       for (i = 0; i < n; i++) {
+               if (ids[i] > sizeof(ioat->xstats)/sizeof(*stats))
+                       values[i] = 0;
+               else
+                       values[i] = stats[ids[i]];
+       }
+       return n;
+}
+
+int
+ioat_xstats_get_names(const struct rte_rawdev *dev,
+               struct rte_rawdev_xstats_name *names,
+               unsigned int size)
+{
+       unsigned int i;
+
+       RTE_SET_USED(dev);
+       if (size < RTE_DIM(xstat_names))
+               return RTE_DIM(xstat_names);
+
+       for (i = 0; i < RTE_DIM(xstat_names); i++)
+               strlcpy(names[i].name, xstat_names[i], sizeof(names[i]));
+
+       return RTE_DIM(xstat_names);
+}
+
+int
+ioat_xstats_reset(struct rte_rawdev *dev, const uint32_t *ids, uint32_t nb_ids)
+{
+       struct rte_ioat_rawdev *ioat = dev->dev_private;
+       uint64_t *stats = (void *)&ioat->xstats;
+       unsigned int i;
+
+       if (!ids) {
+               memset(&ioat->xstats, 0, sizeof(ioat->xstats));
+               return 0;
+       }
+
+       for (i = 0; i < nb_ids; i++)
+               if (ids[i] < sizeof(ioat->xstats)/sizeof(*stats))
+                       stats[ids[i]] = 0;
+
+       return 0;
+}
+
 int
 idxd_rawdev_close(struct rte_rawdev *dev __rte_unused)
 {
index 0f80d60..ab9a3e6 100644 (file)
@@ -53,6 +53,16 @@ struct idxd_rawdev {
        } u;
 };
 
+int ioat_xstats_get(const struct rte_rawdev *dev, const unsigned int ids[],
+               uint64_t values[], unsigned int n);
+
+int ioat_xstats_get_names(const struct rte_rawdev *dev,
+               struct rte_rawdev_xstats_name *names,
+               unsigned int size);
+
+int ioat_xstats_reset(struct rte_rawdev *dev, const uint32_t *ids,
+               uint32_t nb_ids);
+
 extern int idxd_rawdev_create(const char *name, struct rte_device *dev,
                       const struct idxd_rawdev *idxd,
                       const struct rte_rawdev_ops *ops);
index 4ea913f..dd2543c 100644 (file)
@@ -122,64 +122,6 @@ ioat_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info,
        return 0;
 }
 
-static const char * const xstat_names[] = {
-               "failed_enqueues", "successful_enqueues",
-               "copies_started", "copies_completed"
-};
-
-static int
-ioat_xstats_get(const struct rte_rawdev *dev, const unsigned int ids[],
-               uint64_t values[], unsigned int n)
-{
-       const struct rte_ioat_rawdev *ioat = dev->dev_private;
-       const uint64_t *stats = (const void *)&ioat->xstats;
-       unsigned int i;
-
-       for (i = 0; i < n; i++) {
-               if (ids[i] < sizeof(ioat->xstats)/sizeof(*stats))
-                       values[i] = stats[ids[i]];
-               else
-                       values[i] = 0;
-       }
-       return n;
-}
-
-static int
-ioat_xstats_get_names(const struct rte_rawdev *dev,
-               struct rte_rawdev_xstats_name *names,
-               unsigned int size)
-{
-       unsigned int i;
-
-       RTE_SET_USED(dev);
-       if (size < RTE_DIM(xstat_names))
-               return RTE_DIM(xstat_names);
-
-       for (i = 0; i < RTE_DIM(xstat_names); i++)
-               strlcpy(names[i].name, xstat_names[i], sizeof(names[i]));
-
-       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;
-       uint64_t *stats = (void *)&ioat->xstats;
-       unsigned int i;
-
-       if (!ids) {
-               memset(&ioat->xstats, 0, sizeof(ioat->xstats));
-               return 0;
-       }
-
-       for (i = 0; i < nb_ids; i++)
-               if (ids[i] < sizeof(ioat->xstats)/sizeof(*stats))
-                       stats[ids[i]] = 0;
-
-       return 0;
-}
-
 static int
 ioat_dev_close(struct rte_rawdev *dev __rte_unused)
 {