From patchwork Sun Apr 23 05:14:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Yalavarthi X-Patchwork-Id: 126431 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B247A429BA; Sun, 23 Apr 2023 07:14:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 965D042D2C; Sun, 23 Apr 2023 07:14:14 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 6A1C540156 for ; Sun, 23 Apr 2023 07:14:12 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33N4pXa7019841 for ; Sat, 22 Apr 2023 22:14:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=/t3aGAy/hXbBg8yoRTJhDNkP2rsWThu4QwVzWsvgFRQ=; b=ipZO/wXDgaxeDa22XCQQUL8A975uuwJSHLi7T4ptGzIuNWCLlkeFBfsAZBsDMgJsf1+7 wyLNTwjEGmdhs8trfDHdlNgJHRWrIL9kGvZ0ph19riBLJ250i2je04Z65lAJscbZZNry k+0jXrpzQeIDswiev4Bt+eJByR1MT6t42TK5v1s0Cpc51Iu1G6fueXV5vo9iDOTae75X CxjtTgG6aNs2LgVcek6jxZQrktIvTf45ylBt2+ZIcNtv91SLr0PNlwIrcE5FFWkrUPrY QM4lqEGI0znQv50466OH6DNv/hyPRdf19MXTzTHKbwCYLPAnVvQgERuI9fqbtyZ8T5DU qA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3q4egjjvd5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sat, 22 Apr 2023 22:14:11 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sat, 22 Apr 2023 22:14:09 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Sat, 22 Apr 2023 22:14:09 -0700 Received: from ml-host-33.caveonetworks.com (unknown [10.110.143.233]) by maili.marvell.com (Postfix) with ESMTP id 65A873F706A; Sat, 22 Apr 2023 22:14:09 -0700 (PDT) From: Srikanth Yalavarthi To: Srikanth Yalavarthi CC: , , , Subject: [PATCH v1 3/5] mldev: implement xstats library functions Date: Sat, 22 Apr 2023 22:14:01 -0700 Message-ID: <20230423051403.31971-4-syalavarthi@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230423051403.31971-1-syalavarthi@marvell.com> References: <20230423051403.31971-1-syalavarthi@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: hdGPQRjGnt8WgPAyt1lm1wvmMImpfXYG X-Proofpoint-GUID: hdGPQRjGnt8WgPAyt1lm1wvmMImpfXYG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-23_02,2023-04-21_01,2023-02-09_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Implemented xstats library functions as per revised spec. Signed-off-by: Srikanth Yalavarthi --- 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;