From: Srikanth Yalavarthi <syalavarthi@marvell.com>
To: Srikanth Yalavarthi <syalavarthi@marvell.com>
Cc: <dev@dpdk.org>, <sshankarnara@marvell.com>, <aprabhu@marvell.com>,
<ptakkar@marvell.com>
Subject: [PATCH v1 3/5] mldev: implement xstats library functions
Date: Sat, 22 Apr 2023 22:14:01 -0700 [thread overview]
Message-ID: <20230423051403.31971-4-syalavarthi@marvell.com> (raw)
In-Reply-To: <20230423051403.31971-1-syalavarthi@marvell.com>
Implemented xstats library functions as per revised spec.
Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
lib/mldev/rte_mldev.c | 91 +++++++++++++++++++++++++++++++
lib/mldev/rte_mldev_core.h | 107 +++++++++++++++++++++++++++++++++++++
lib/mldev/version.map | 4 ++
3 files changed, 202 insertions(+)
diff --git a/lib/mldev/rte_mldev.c b/lib/mldev/rte_mldev.c
index 72d4d7a165..0d8ccd3212 100644
--- a/lib/mldev/rte_mldev.c
+++ b/lib/mldev/rte_mldev.c
@@ -438,6 +438,97 @@ rte_ml_dev_stats_reset(int16_t dev_id)
(*dev->dev_ops->dev_stats_reset)(dev);
}
+int
+rte_ml_dev_xstats_names_get(int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id,
+ struct rte_ml_dev_xstats_map *xstats_map, uint32_t size)
+{
+ struct rte_ml_dev *dev;
+
+ if (!rte_ml_dev_is_valid_dev(dev_id)) {
+ RTE_MLDEV_LOG(ERR, "Invalid dev_id = %d\n", dev_id);
+ return -EINVAL;
+ }
+
+ dev = rte_ml_dev_pmd_get_dev(dev_id);
+ if (*dev->dev_ops->dev_xstats_names_get == NULL)
+ return -ENOTSUP;
+
+ return (*dev->dev_ops->dev_xstats_names_get)(dev, mode, model_id, xstats_map, size);
+}
+
+int
+rte_ml_dev_xstats_by_name_get(int16_t dev_id, const char *name, uint16_t *stat_id, uint64_t *value)
+{
+ struct rte_ml_dev *dev;
+
+ if (!rte_ml_dev_is_valid_dev(dev_id)) {
+ RTE_MLDEV_LOG(ERR, "Invalid dev_id = %d\n", dev_id);
+ return -EINVAL;
+ }
+
+ dev = rte_ml_dev_pmd_get_dev(dev_id);
+ if (*dev->dev_ops->dev_xstats_by_name_get == NULL)
+ return -ENOTSUP;
+
+ if (name == NULL) {
+ RTE_MLDEV_LOG(ERR, "Dev %d, name cannot be NULL\n", dev_id);
+ return -EINVAL;
+ }
+
+ if (value == NULL) {
+ RTE_MLDEV_LOG(ERR, "Dev %d, value cannot be NULL\n", dev_id);
+ return -EINVAL;
+ }
+
+ return (*dev->dev_ops->dev_xstats_by_name_get)(dev, name, stat_id, value);
+}
+
+int
+rte_ml_dev_xstats_get(int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id,
+ const uint16_t stat_ids[], uint64_t values[], uint16_t nb_ids)
+{
+ struct rte_ml_dev *dev;
+
+ if (!rte_ml_dev_is_valid_dev(dev_id)) {
+ RTE_MLDEV_LOG(ERR, "Invalid dev_id = %d\n", dev_id);
+ return -EINVAL;
+ }
+
+ dev = rte_ml_dev_pmd_get_dev(dev_id);
+ if (*dev->dev_ops->dev_xstats_get == NULL)
+ return -ENOTSUP;
+
+ if (stat_ids == NULL) {
+ RTE_MLDEV_LOG(ERR, "Dev %d, stat_ids cannot be NULL\n", dev_id);
+ return -EINVAL;
+ }
+
+ if (values == NULL) {
+ RTE_MLDEV_LOG(ERR, "Dev %d, values cannot be NULL\n", dev_id);
+ return -EINVAL;
+ }
+
+ return (*dev->dev_ops->dev_xstats_get)(dev, mode, model_id, stat_ids, values, nb_ids);
+}
+
+int
+rte_ml_dev_xstats_reset(int16_t dev_id, enum rte_ml_dev_xstats_mode mode, int32_t model_id,
+ const uint16_t stat_ids[], uint16_t nb_ids)
+{
+ struct rte_ml_dev *dev;
+
+ if (!rte_ml_dev_is_valid_dev(dev_id)) {
+ RTE_MLDEV_LOG(ERR, "Invalid dev_id = %d\n", dev_id);
+ return -EINVAL;
+ }
+
+ dev = rte_ml_dev_pmd_get_dev(dev_id);
+ if (*dev->dev_ops->dev_xstats_reset == NULL)
+ return -ENOTSUP;
+
+ return (*dev->dev_ops->dev_xstats_reset)(dev, mode, model_id, stat_ids, nb_ids);
+}
+
int
rte_ml_dev_dump(int16_t dev_id, FILE *fd)
{
diff --git a/lib/mldev/rte_mldev_core.h b/lib/mldev/rte_mldev_core.h
index 926a652397..78b8b7633d 100644
--- a/lib/mldev/rte_mldev_core.h
+++ b/lib/mldev/rte_mldev_core.h
@@ -236,6 +236,101 @@ typedef int (*mldev_stats_get_t)(struct rte_ml_dev *dev, struct rte_ml_dev_stats
*/
typedef void (*mldev_stats_reset_t)(struct rte_ml_dev *dev);
+/**
+ * @internal
+ *
+ * Function used to get names of extended stats.
+ *
+ * @param dev
+ * ML device pointer.
+ * @param mode
+ * Mode of stats to retrieve.
+ * @param model_id
+ * Used to specify model id in model mode. Ignored in device mode.
+ * @param xstats_map
+ * Array to insert id and names into.
+ * @param size
+ * Size of xstats_map array.
+ *
+ * @return
+ * - >= 0 and <= size on success.
+ * - > size, error. Returns the size of xstats_map array required.
+ * - < 0, error code on failure.
+ */
+typedef int (*mldev_xstats_names_get_t)(struct rte_ml_dev *dev, enum rte_ml_dev_xstats_mode mode,
+ int32_t model_id, struct rte_ml_dev_xstats_map *xstats_map,
+ uint32_t size);
+
+/**
+ * @internal
+ *
+ * Function used to get a single extended stat by name.
+ *
+ * @param dev
+ * ML device pointer.
+ * @param name
+ * Name of the stat to retrieve.
+ * @param stat_id
+ * ID of the stat to be returned.
+ * @param value
+ * Value of the stat to be returned.
+ *
+ * @return
+ * - = 0 success.
+ * - < 0, error code on failure.
+ */
+typedef int (*mldev_xstats_by_name_get_t)(struct rte_ml_dev *dev, const char *name,
+ uint16_t *stat_id, uint64_t *value);
+
+/**
+ * @internal
+ *
+ * Function used to retrieve extended stats of a device.
+ *
+ * @param dev
+ * ML device pointer.
+ * @param mode
+ * Mode of stats to retrieve.
+ * @param model_id
+ * Used to specify model id in model mode. Ignored in device mode.
+ * @param stat_ids
+ * Array of ID numbers of the stats to be retrieved.
+ * @param values
+ * Values of the stats requested by the ID.
+ * @param nb_ids
+ * Number of stats requested.
+ *
+ * @return
+ * - >= 0, number of entries filled into the values array.
+ * - < 0, error code on failure.
+ */
+typedef int (*mldev_xstats_get_t)(struct rte_ml_dev *dev, enum rte_ml_dev_xstats_mode mode,
+ int32_t model_id, const uint16_t stat_ids[], uint64_t values[],
+ uint16_t nb_ids);
+
+/**
+ * @internal
+ *
+ * Function used to reset extended stats.
+ *
+ * @param dev
+ * ML device pointer.
+ * @param mode
+ * Mode of stats to retrieve.
+ * @param model_id
+ * Used to specify model id in model mode. Ignored in device mode.
+ * @param stat_ids
+ * Array of stats IDs to be reset.
+ * @param nb_ids
+ * Number of IDs in the stat_ids array.
+ *
+ * @return
+ * - 0 on success.
+ * - < 0, error code on failure.
+ */
+typedef int (*mldev_xstats_reset_t)(struct rte_ml_dev *dev, enum rte_ml_dev_xstats_mode mode,
+ int32_t model_id, const uint16_t stat_ids[], uint16_t nb_ids);
+
/**
* @internal
*
@@ -498,6 +593,18 @@ struct rte_ml_dev_ops {
/** Reset device statistics. */
mldev_stats_reset_t dev_stats_reset;
+ /** Get names of extended stats. */
+ mldev_xstats_names_get_t dev_xstats_names_get;
+
+ /** Get value of a single extended stat. */
+ mldev_xstats_by_name_get_t dev_xstats_by_name_get;
+
+ /** Get extended stats of a device. */
+ mldev_xstats_get_t dev_xstats_get;
+
+ /** Reset extended stats of the device. */
+ mldev_xstats_reset_t dev_xstats_reset;
+
/** Dump ML device debug info. */
mldev_dump_t dev_dump;
diff --git a/lib/mldev/version.map b/lib/mldev/version.map
index c774a87a5e..0706b565be 100644
--- a/lib/mldev/version.map
+++ b/lib/mldev/version.map
@@ -17,6 +17,10 @@ EXPERIMENTAL {
rte_ml_dev_stats_get;
rte_ml_dev_stats_reset;
rte_ml_dev_stop;
+ rte_ml_dev_xstats_by_name_get;
+ rte_ml_dev_xstats_get;
+ rte_ml_dev_xstats_names_get;
+ rte_ml_dev_xstats_reset;
rte_ml_enqueue_burst;
rte_ml_io_dequantize;
rte_ml_io_input_size_get;
--
2.17.1
next prev parent reply other threads:[~2023-04-23 5:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-23 5:13 [PATCH v1 0/5] Implementation of revised ML xstats spec Srikanth Yalavarthi
2023-04-23 5:13 ` [PATCH v1 1/5] mldev: remove xstats APIs from library Srikanth Yalavarthi
2023-04-23 5:14 ` [PATCH v1 2/5] mldev: introduce revised xstats Srikanth Yalavarthi
2023-04-23 5:14 ` Srikanth Yalavarthi [this message]
2023-04-23 5:14 ` [PATCH v1 4/5] app/mldev: enable reporting xstats Srikanth Yalavarthi
2023-04-23 5:14 ` [PATCH v1 5/5] ml/cnxk: implement xstats driver functions Srikanth Yalavarthi
2023-06-06 13:40 ` [PATCH v1 0/5] Implementation of revised ML xstats spec Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230423051403.31971-4-syalavarthi@marvell.com \
--to=syalavarthi@marvell.com \
--cc=aprabhu@marvell.com \
--cc=dev@dpdk.org \
--cc=ptakkar@marvell.com \
--cc=sshankarnara@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).