From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5826441EB5; Thu, 16 Mar 2023 22:15:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 04D3742F86; Thu, 16 Mar 2023 22:14:48 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 8F73340DDC for ; Thu, 16 Mar 2023 22:14:43 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32GJMmih016125 for ; Thu, 16 Mar 2023 14:14:43 -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=GItS5lLvmKyezheQ9jRBLPR3pB37shjob88ThCLnkyA=; b=Mp5qrEKfCyCN3CELkJVFCImCnh+CHMctX4wgjcH3y75Sf6KWhqMxYX3EW888WnE0bhzf 8u0YgQyw3QmLztFWunq2vPKZa8hFwuXHzqCZN91kWjm1bOzbasR6UJGgXbnTiBcpjDl9 zXPy7cP6YzASBiqf/CVLffhfdnYw4zF01wkv5sc1X0OXQImNw2SXsrwTX56v00NKM/x4 O5UhRTyZITwV3pGPwfqcUZR7UZLsx7yLbp0uTToU866kCJz3Bpp73C+HWbUdPJKxAG8/ 5wmbBxphu2e1PB5uIYsn1XSqyVle17RbXHwO+jkrvzKM0iCA0oEB4S+U7j+I2QiIMq5f VQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3pbs2u3mk5-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 16 Mar 2023 14:14:42 -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.42; Thu, 16 Mar 2023 14:14:40 -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.42 via Frontend Transport; Thu, 16 Mar 2023 14:14:39 -0700 Received: from ml-host-33.caveonetworks.com (unknown [10.110.143.233]) by maili.marvell.com (Postfix) with ESMTP id E18E93F707D; Thu, 16 Mar 2023 14:14:39 -0700 (PDT) From: Srikanth Yalavarthi To: Srikanth Yalavarthi CC: , , , , , Subject: [PATCH v7 03/11] app/mldev: add test case to validate device ops Date: Thu, 16 Mar 2023 14:14:26 -0700 Message-ID: <20230316211434.13409-4-syalavarthi@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230316211434.13409-1-syalavarthi@marvell.com> References: <20221129070746.20396-1-syalavarthi@marvell.com> <20230316211434.13409-1-syalavarthi@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: 9QTXDmYnk59MYSjTZVjiH2hY_DJTrxC- X-Proofpoint-ORIG-GUID: 9QTXDmYnk59MYSjTZVjiH2hY_DJTrxC- 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-03-16_14,2023-03-16_02,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 Added test case to validate device handling operations. Device ops test is a collection of multiple sub-tests. Enabled sub-test to validate device reconfiguration. Set device_ops as the default test. Signed-off-by: Srikanth Yalavarthi Acked-by: Anup Prabhu --- app/test-mldev/meson.build | 1 + app/test-mldev/ml_options.c | 5 +- app/test-mldev/ml_options.h | 2 + app/test-mldev/test_device_ops.c | 228 +++++++++++++++++++++++++++++++ app/test-mldev/test_device_ops.h | 17 +++ doc/guides/tools/testmldev.rst | 42 +++++- 6 files changed, 292 insertions(+), 3 deletions(-) create mode 100644 app/test-mldev/test_device_ops.c create mode 100644 app/test-mldev/test_device_ops.h diff --git a/app/test-mldev/meson.build b/app/test-mldev/meson.build index 964bb9ddc4..60ea23d142 100644 --- a/app/test-mldev/meson.build +++ b/app/test-mldev/meson.build @@ -13,6 +13,7 @@ sources = files( 'ml_test.c', 'parser.c', 'test_common.c', + 'test_device_ops.c', ) deps += ['mldev'] diff --git a/app/test-mldev/ml_options.c b/app/test-mldev/ml_options.c index 37559614b1..854d316521 100644 --- a/app/test-mldev/ml_options.c +++ b/app/test-mldev/ml_options.c @@ -19,7 +19,7 @@ void ml_options_default(struct ml_options *opt) { memset(opt, 0, sizeof(*opt)); - strlcpy(opt->test_name, "ml_test", ML_TEST_NAME_MAX_LEN); + strlcpy(opt->test_name, "device_ops", ML_TEST_NAME_MAX_LEN); opt->dev_id = 0; opt->socket_id = SOCKET_ID_ANY; opt->debug = false; @@ -61,7 +61,8 @@ ml_parse_socket_id(struct ml_options *opt, const char *arg) static void ml_dump_test_options(const char *testname) { - RTE_SET_USED(testname); + if (strcmp(testname, "device_ops") == 0) + printf("\n"); } static void diff --git a/app/test-mldev/ml_options.h b/app/test-mldev/ml_options.h index 05311a9a47..6899cc2f88 100644 --- a/app/test-mldev/ml_options.h +++ b/app/test-mldev/ml_options.h @@ -9,6 +9,7 @@ #include #define ML_TEST_NAME_MAX_LEN 32 +#define ML_TEST_MAX_MODELS 8 /* Options names */ #define ML_TEST ("test") @@ -21,6 +22,7 @@ struct ml_options { char test_name[ML_TEST_NAME_MAX_LEN]; int16_t dev_id; int socket_id; + uint8_t nb_filelist; bool debug; }; diff --git a/app/test-mldev/test_device_ops.c b/app/test-mldev/test_device_ops.c new file mode 100644 index 0000000000..be0c5f0780 --- /dev/null +++ b/app/test-mldev/test_device_ops.c @@ -0,0 +1,228 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 Marvell. + */ + +#include + +#include +#include +#include + +#include "test_device_ops.h" + +static bool +test_device_cap_check(struct ml_options *opt) +{ + if (!ml_test_cap_check(opt)) + return false; + + return true; +} + +static int +test_device_opt_check(struct ml_options *opt) +{ + int ret; + + /* check common opts */ + ret = ml_test_opt_check(opt); + if (ret != 0) + return ret; + + return 0; +} + +static void +test_device_opt_dump(struct ml_options *opt) +{ + /* dump common opts */ + ml_test_opt_dump(opt); +} + +static int +test_device_setup(struct ml_test *test, struct ml_options *opt) +{ + struct test_device *t; + void *test_device; + int ret = 0; + + /* allocate for test structure */ + test_device = rte_zmalloc_socket(test->name, sizeof(struct test_device), + RTE_CACHE_LINE_SIZE, opt->socket_id); + if (test_device == NULL) { + ml_err("failed to allocate memory for test_model"); + ret = -ENOMEM; + goto error; + } + test->test_priv = test_device; + t = ml_test_priv(test); + + t->cmn.result = ML_TEST_FAILED; + t->cmn.opt = opt; + + /* get device info */ + ret = rte_ml_dev_info_get(opt->dev_id, &t->cmn.dev_info); + if (ret < 0) { + ml_err("failed to get device info"); + goto error; + } + + return 0; + +error: + if (test_device != NULL) + rte_free(test_device); + + return ret; +} + +static void +test_device_destroy(struct ml_test *test, struct ml_options *opt) +{ + struct test_device *t; + + RTE_SET_USED(opt); + + t = ml_test_priv(test); + if (t != NULL) + rte_free(t); +} + +static int +test_device_reconfigure(struct ml_test *test, struct ml_options *opt) +{ + struct rte_ml_dev_config dev_config; + struct rte_ml_dev_qp_conf qp_conf; + struct test_device *t; + uint16_t qp_id = 0; + int ret = 0; + + t = ml_test_priv(test); + + /* configure with default options */ + ret = ml_test_device_configure(test, opt); + if (ret != 0) + return ret; + + /* setup one queue pair with nb_desc = 1 */ + qp_conf.nb_desc = 1; + qp_conf.cb = NULL; + + ret = rte_ml_dev_queue_pair_setup(opt->dev_id, qp_id, &qp_conf, opt->socket_id); + if (ret != 0) { + ml_err("Failed to setup ML device queue-pair, dev_id = %d, qp_id = %u\n", + opt->dev_id, qp_id); + goto error; + } + + /* start device */ + ret = ml_test_device_start(test, opt); + if (ret != 0) + goto error; + + /* stop device */ + ret = ml_test_device_stop(test, opt); + if (ret != 0) { + ml_err("Failed to stop device"); + goto error; + } + + /* reconfigure device based on dev_info */ + dev_config.socket_id = opt->socket_id; + dev_config.nb_models = t->cmn.dev_info.max_models; + dev_config.nb_queue_pairs = t->cmn.dev_info.max_queue_pairs; + ret = rte_ml_dev_configure(opt->dev_id, &dev_config); + if (ret != 0) { + ml_err("Failed to reconfigure ML device, dev_id = %d\n", opt->dev_id); + return ret; + } + + /* setup queue pairs */ + for (qp_id = 0; qp_id < t->cmn.dev_info.max_queue_pairs; qp_id++) { + qp_conf.nb_desc = t->cmn.dev_info.max_desc; + qp_conf.cb = NULL; + + ret = rte_ml_dev_queue_pair_setup(opt->dev_id, qp_id, &qp_conf, opt->socket_id); + if (ret != 0) { + ml_err("Failed to setup ML device queue-pair, dev_id = %d, qp_id = %u\n", + opt->dev_id, qp_id); + goto error; + } + } + + /* start device */ + ret = ml_test_device_start(test, opt); + if (ret != 0) + goto error; + + /* stop device */ + ret = ml_test_device_stop(test, opt); + if (ret != 0) + goto error; + + /* close device */ + ret = ml_test_device_close(test, opt); + if (ret != 0) + return ret; + + return 0; + +error: + ml_test_device_close(test, opt); + + return ret; +} + +static int +test_device_driver(struct ml_test *test, struct ml_options *opt) +{ + struct test_device *t; + int ret = 0; + + t = ml_test_priv(test); + + /* sub-test: device reconfigure */ + ret = test_device_reconfigure(test, opt); + if (ret != 0) { + printf("\n"); + printf("Model Device Reconfigure Test: " CLRED "%s" CLNRM "\n", "Failed"); + goto error; + } else { + printf("\n"); + printf("Model Device Reconfigure Test: " CLYEL "%s" CLNRM "\n", "Passed"); + } + + printf("\n"); + + t->cmn.result = ML_TEST_SUCCESS; + + return 0; + +error: + t->cmn.result = ML_TEST_FAILED; + return -1; +} + +static int +test_device_result(struct ml_test *test, struct ml_options *opt) +{ + struct test_device *t; + + RTE_SET_USED(opt); + + t = ml_test_priv(test); + + return t->cmn.result; +} + +static const struct ml_test_ops device_ops = { + .cap_check = test_device_cap_check, + .opt_check = test_device_opt_check, + .opt_dump = test_device_opt_dump, + .test_setup = test_device_setup, + .test_destroy = test_device_destroy, + .test_driver = test_device_driver, + .test_result = test_device_result, +}; + +ML_TEST_REGISTER(device_ops); diff --git a/app/test-mldev/test_device_ops.h b/app/test-mldev/test_device_ops.h new file mode 100644 index 0000000000..115b1072a2 --- /dev/null +++ b/app/test-mldev/test_device_ops.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 Marvell. + */ + +#ifndef _ML_TEST_DEVICE_OPS_ +#define _ML_TEST_DEVICE_OPS_ + +#include + +#include "test_common.h" + +struct test_device { + /* common data */ + struct test_common cmn; +} __rte_cache_aligned; + +#endif /* _ML_TEST_DEVICE_OPS_ */ diff --git a/doc/guides/tools/testmldev.rst b/doc/guides/tools/testmldev.rst index 9dd7606d0b..1771c49fb4 100644 --- a/doc/guides/tools/testmldev.rst +++ b/doc/guides/tools/testmldev.rst @@ -44,7 +44,12 @@ The following are the command-line options supported by the test application. * ``--test `` - Name of the test to execute. + Name of the test to execute. ML tests supported include device tests. Test name should be + one of the following supported tests. + + **ML Device Tests** :: + + device_ops * ``--dev_id `` @@ -63,6 +68,41 @@ The following are the command-line options supported by the test application. Print help message. +ML Device Tests +------------------------- + +ML device tests are functional tests to validate ML device APIs. Device tests validate the ML device +handling APIs configure, close, start and stop APIs. + + +Application Options +~~~~~~~~~~~~~~~~~~~ + +Supported command line options for the `device_ops` test are following:: + + --debug + --test + --dev_id + --socket_id + + +DEVICE_OPS Test +~~~~~~~~~~~~~~~ + +Device ops test validates the device configuration and reconfiguration. + + +Example +^^^^^^^ + +Command to run device_ops test: + +.. code-block:: console + + sudo /app/dpdk-test-mldev -c 0xf -a -- \ + --test=device_ops + + Debug mode ---------- -- 2.17.1