Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/120586/?format=api
http://patches.dpdk.org/api/patches/120586/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20221208192918.25022-4-syalavarthi@marvell.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20221208192918.25022-4-syalavarthi@marvell.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20221208192918.25022-4-syalavarthi@marvell.com", "date": "2022-12-08T19:29:10", "name": "[v3,04/12] app/mldev: add test case to validate model ops", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "2feb3b8c6560ad366af36680190a9da9faaac718", "submitter": { "id": 2480, "url": "http://patches.dpdk.org/api/people/2480/?format=api", "name": "Srikanth Yalavarthi", "email": "syalavarthi@marvell.com" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20221208192918.25022-4-syalavarthi@marvell.com/mbox/", "series": [ { "id": 26046, "url": "http://patches.dpdk.org/api/series/26046/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=26046", "date": "2022-12-08T19:29:07", "name": "[v3,01/12] app/mldev: implement test framework for mldev", "version": 3, "mbox": "http://patches.dpdk.org/series/26046/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/120586/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/120586/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "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])\n\tby inbox.dpdk.org (Postfix) with ESMTP id C75F4A00C2;\n\tThu, 8 Dec 2022 20:30:09 +0100 (CET)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 474AE42D34;\n\tThu, 8 Dec 2022 20:29:52 +0100 (CET)", "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174])\n by mails.dpdk.org (Postfix) with ESMTP id B94834003F\n for <dev@dpdk.org>; Thu, 8 Dec 2022 20:29:47 +0100 (CET)", "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 2B8J8Kix001346 for <dev@dpdk.org>; Thu, 8 Dec 2022 11:29:46 -0800", "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3mb22svjux-2\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Thu, 08 Dec 2022 11:29:46 -0800", "from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18;\n Thu, 8 Dec 2022 11:29:44 -0800", "from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend\n Transport; Thu, 8 Dec 2022 11:29:44 -0800", "from ml-host-33.caveonetworks.com (unknown [10.110.143.233])\n by maili.marvell.com (Postfix) with ESMTP id A41AB3F706F;\n Thu, 8 Dec 2022 11:29:44 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-type; s=pfpt0220; bh=YZ3ns0a9Ic9tcaRZnYRT37/UYRrne/Ey8ogVRQ+9hhw=;\n b=fGLo7DaPIlK7Tl02zzi9RJpWRk76wtHWy2t1Tv3gJIjefIKjRxMIMl2Qew0WF9G8++z0\n NkUDA1OO8UAj/dE+FIcboIgziUNDuPuzNyGoPGcDbovcY2cjii0ihlVPK+tyYBR5Ia+F\n XavLIZpXNU4xML6/gd9yZ6y/Mhxtlt8IzVWs8tlw/JlawM1pJi+KVno2pzzQQnegnlZW\n xEHuouESfzaAhQtPNYM/Hzo9zeZGElQC0a8/+E2Y/takuaERP0r3h6I2CQMiAML/Gs3w\n dP3VLGTbVsZ1qkirM6zxg7wJpPb+1z1cpwrsUP4lsrd4i7yrQT9382WOZBl+hHKPJ4Sw cw==", "From": "Srikanth Yalavarthi <syalavarthi@marvell.com>", "To": "Srikanth Yalavarthi <syalavarthi@marvell.com>", "CC": "<dev@dpdk.org>, <sshankarnara@marvell.com>, <jerinj@marvell.com>,\n <aprabhu@marvell.com>", "Subject": "[PATCH v3 04/12] app/mldev: add test case to validate model ops", "Date": "Thu, 8 Dec 2022 11:29:10 -0800", "Message-ID": "<20221208192918.25022-4-syalavarthi@marvell.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20221208192918.25022-1-syalavarthi@marvell.com>", "References": "<20221129082109.6809-1-syalavarthi@marvell.com>\n <20221208192918.25022-1-syalavarthi@marvell.com>", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Proofpoint-ORIG-GUID": "RNIwOUhJzbggpCrthr4tbMcgVyKoXGRP", "X-Proofpoint-GUID": "RNIwOUhJzbggpCrthr4tbMcgVyKoXGRP", "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1\n definitions=2022-12-08_11,2022-12-08_01,2022-06-22_01", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "Added test case to validate model operations. Model ops test\nis a collection of sub-tests. Each sub-test invokes the model\noperations in a specific order.\n\nSub-test A: (load -> start -> stop -> unload) x n\nSub-test B: load x n -> start x n -> stop x n -> unload x n\nSub-test C: load x n + (start + stop) x n + unload x n\nSub-test D: (load + start) x n -> (stop + unload) x n\n\nAdded internal functions to handle model load, start, stop and\nunload. List of models to be used for testing can be specified\nthrough application argument \"--models\"\n\nSigned-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>\n---\n app/test-mldev/meson.build | 2 +\n app/test-mldev/ml_options.c | 45 ++-\n app/test-mldev/ml_options.h | 9 +\n app/test-mldev/test_model_common.c | 162 +++++++++++\n app/test-mldev/test_model_common.h | 37 +++\n app/test-mldev/test_model_ops.c | 433 +++++++++++++++++++++++++++++\n app/test-mldev/test_model_ops.h | 21 ++\n 7 files changed, 706 insertions(+), 3 deletions(-)\n create mode 100644 app/test-mldev/test_model_common.c\n create mode 100644 app/test-mldev/test_model_common.h\n create mode 100644 app/test-mldev/test_model_ops.c\n create mode 100644 app/test-mldev/test_model_ops.h", "diff": "diff --git a/app/test-mldev/meson.build b/app/test-mldev/meson.build\nindex 60ea23d142..b09e1ccc8a 100644\n--- a/app/test-mldev/meson.build\n+++ b/app/test-mldev/meson.build\n@@ -14,6 +14,8 @@ sources = files(\n 'parser.c',\n 'test_common.c',\n 'test_device_ops.c',\n+ 'test_model_common.c',\n+ 'test_model_ops.c',\n )\n \n deps += ['mldev']\ndiff --git a/app/test-mldev/ml_options.c b/app/test-mldev/ml_options.c\nindex 2e5f11bca2..15043c0992 100644\n--- a/app/test-mldev/ml_options.c\n+++ b/app/test-mldev/ml_options.c\n@@ -4,6 +4,7 @@\n \n #include <errno.h>\n #include <getopt.h>\n+#include <linux/limits.h>\n #include <stdbool.h>\n #include <stdio.h>\n #include <stdlib.h>\n@@ -27,6 +28,7 @@ ml_options_default(struct ml_options *opt)\n \tstrlcpy(opt->test_name, \"device_ops\", ML_TEST_NAME_MAX_LEN);\n \topt->dev_id = 0;\n \topt->socket_id = SOCKET_ID_ANY;\n+\topt->nb_filelist = 0;\n \topt->debug = false;\n }\n \n@@ -63,11 +65,47 @@ ml_parse_socket_id(struct ml_options *opt, const char *arg)\n \treturn 0;\n }\n \n+static int\n+ml_parse_models(struct ml_options *opt, const char *arg)\n+{\n+\tconst char *delim = \",\";\n+\tchar models[PATH_MAX];\n+\tchar *token;\n+\tint ret = 0;\n+\n+\tstrlcpy(models, arg, PATH_MAX);\n+\n+\ttoken = strtok(models, delim);\n+\twhile (token != NULL) {\n+\t\tstrlcpy(opt->filelist[opt->nb_filelist].model, token, PATH_MAX);\n+\t\topt->nb_filelist++;\n+\n+\t\tif (opt->nb_filelist >= ML_TEST_MAX_MODELS) {\n+\t\t\tml_err(\"Exceeded model count, max = %d\\n\", ML_TEST_MAX_MODELS);\n+\t\t\tret = -EINVAL;\n+\t\t\tbreak;\n+\t\t}\n+\t\ttoken = strtok(NULL, delim);\n+\t}\n+\n+\tif (opt->nb_filelist == 0) {\n+\t\tml_err(\"Models list is empty. Need at least one model for the test\");\n+\t\tret = -EINVAL;\n+\t}\n+\n+\treturn ret;\n+}\n+\n static void\n ml_dump_test_options(const char *testname)\n {\n \tif (strcmp(testname, \"device_ops\") == 0)\n \t\tprintf(\"\\n\");\n+\n+\tif (strcmp(testname, \"model_ops\") == 0) {\n+\t\tprintf(\"\\t\\t--models : comma separated list of models\\n\");\n+\t\tprintf(\"\\n\");\n+\t}\n }\n \n static void\n@@ -85,9 +123,9 @@ print_usage(char *program)\n \tml_test_dump_names(ml_dump_test_options);\n }\n \n-static struct option lgopts[] = {{ML_TEST, 1, 0, 0},\t {ML_DEVICE_ID, 1, 0, 0},\n-\t\t\t\t {ML_SOCKET_ID, 1, 0, 0}, {ML_DEBUG, 0, 0, 0},\n-\t\t\t\t {ML_HELP, 0, 0, 0},\t {NULL, 0, 0, 0}};\n+static struct option lgopts[] = {\n+\t{ML_TEST, 1, 0, 0}, {ML_DEVICE_ID, 1, 0, 0}, {ML_SOCKET_ID, 1, 0, 0}, {ML_MODELS, 1, 0, 0},\n+\t{ML_DEBUG, 0, 0, 0}, {ML_HELP, 0, 0, 0}, {NULL, 0, 0, 0}};\n \n static int\n ml_opts_parse_long(int opt_idx, struct ml_options *opt)\n@@ -98,6 +136,7 @@ ml_opts_parse_long(int opt_idx, struct ml_options *opt)\n \t\t{ML_TEST, ml_parse_test_name},\n \t\t{ML_DEVICE_ID, ml_parse_dev_id},\n \t\t{ML_SOCKET_ID, ml_parse_socket_id},\n+\t\t{ML_MODELS, ml_parse_models},\n \t};\n \n \tfor (i = 0; i < RTE_DIM(parsermap); i++) {\ndiff --git a/app/test-mldev/ml_options.h b/app/test-mldev/ml_options.h\nindex 05311a9a47..8faf3b5deb 100644\n--- a/app/test-mldev/ml_options.h\n+++ b/app/test-mldev/ml_options.h\n@@ -5,22 +5,31 @@\n #ifndef _ML_OPTIONS_\n #define _ML_OPTIONS_\n \n+#include <linux/limits.h>\n #include <stdbool.h>\n #include <stdint.h>\n \n #define ML_TEST_NAME_MAX_LEN 32\n+#define ML_TEST_MAX_MODELS 8\n \n /* Options names */\n #define ML_TEST\t (\"test\")\n #define ML_DEVICE_ID (\"dev_id\")\n #define ML_SOCKET_ID (\"socket_id\")\n+#define ML_MODELS (\"models\")\n #define ML_DEBUG (\"debug\")\n #define ML_HELP\t (\"help\")\n \n+struct ml_filelist {\n+\tchar model[PATH_MAX];\n+};\n+\n struct ml_options {\n \tchar test_name[ML_TEST_NAME_MAX_LEN];\n \tint16_t dev_id;\n \tint socket_id;\n+\tstruct ml_filelist filelist[ML_TEST_MAX_MODELS];\n+\tuint8_t nb_filelist;\n \tbool debug;\n };\n \ndiff --git a/app/test-mldev/test_model_common.c b/app/test-mldev/test_model_common.c\nnew file mode 100644\nindex 0000000000..5368be17fe\n--- /dev/null\n+++ b/app/test-mldev/test_model_common.c\n@@ -0,0 +1,162 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2022 Marvell.\n+ */\n+\n+#include <errno.h>\n+#include <stdio.h>\n+\n+#include <rte_common.h>\n+#include <rte_malloc.h>\n+#include <rte_mldev.h>\n+\n+#include \"ml_common.h\"\n+#include \"ml_options.h\"\n+#include \"ml_test.h\"\n+#include \"test_common.h\"\n+#include \"test_model_common.h\"\n+\n+int\n+ml_model_load(struct ml_test *test, struct ml_options *opt, struct ml_model *model, int16_t fid)\n+{\n+\tstruct test_common *t = ml_test_priv(test);\n+\tstruct rte_ml_model_params model_params;\n+\tFILE *fp;\n+\tint ret;\n+\n+\tif (model->state == MODEL_LOADED)\n+\t\treturn 0;\n+\n+\tif (model->state != MODEL_INITIAL)\n+\t\treturn -EINVAL;\n+\n+\t/* read model binary */\n+\tfp = fopen(opt->filelist[fid].model, \"r\");\n+\tif (fp == NULL) {\n+\t\tml_err(\"Failed to open model file : %s\\n\", opt->filelist[fid].model);\n+\t\treturn -1;\n+\t}\n+\n+\tfseek(fp, 0, SEEK_END);\n+\tmodel_params.size = ftell(fp);\n+\tfseek(fp, 0, SEEK_SET);\n+\n+\tmodel_params.addr = rte_malloc_socket(\"ml_model\", model_params.size,\n+\t\t\t\t\t t->dev_info.min_align_size, opt->socket_id);\n+\tif (model_params.addr == NULL) {\n+\t\tml_err(\"Failed to allocate memory for model: %s\\n\", opt->filelist[fid].model);\n+\t\tfclose(fp);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tif (fread(model_params.addr, 1, model_params.size, fp) != model_params.size) {\n+\t\tml_err(\"Failed to read model file : %s\\n\", opt->filelist[fid].model);\n+\t\trte_free(model_params.addr);\n+\t\tfclose(fp);\n+\t\treturn -1;\n+\t}\n+\tfclose(fp);\n+\n+\t/* load model to device */\n+\tret = rte_ml_model_load(opt->dev_id, &model_params, &model->id);\n+\tif (ret != 0) {\n+\t\tml_err(\"Failed to load model : %s\\n\", opt->filelist[fid].model);\n+\t\tmodel->state = MODEL_ERROR;\n+\t\trte_free(model_params.addr);\n+\t\treturn ret;\n+\t}\n+\n+\t/* release mz */\n+\trte_free(model_params.addr);\n+\n+\t/* get model info */\n+\tret = rte_ml_model_info_get(opt->dev_id, model->id, &model->info);\n+\tif (ret != 0) {\n+\t\tml_err(\"Failed to get model info : %s\\n\", opt->filelist[fid].model);\n+\t\treturn ret;\n+\t}\n+\n+\tmodel->state = MODEL_LOADED;\n+\n+\treturn 0;\n+}\n+\n+int\n+ml_model_unload(struct ml_test *test, struct ml_options *opt, struct ml_model *model, int16_t fid)\n+{\n+\tstruct test_common *t = ml_test_priv(test);\n+\tint ret;\n+\n+\tRTE_SET_USED(t);\n+\n+\tif (model->state == MODEL_INITIAL)\n+\t\treturn 0;\n+\n+\tif (model->state != MODEL_LOADED)\n+\t\treturn -EINVAL;\n+\n+\t/* unload model */\n+\tret = rte_ml_model_unload(opt->dev_id, model->id);\n+\tif (ret != 0) {\n+\t\tml_err(\"Failed to unload model: %s\\n\", opt->filelist[fid].model);\n+\t\tmodel->state = MODEL_ERROR;\n+\t\treturn ret;\n+\t}\n+\n+\tmodel->state = MODEL_INITIAL;\n+\n+\treturn 0;\n+}\n+\n+int\n+ml_model_start(struct ml_test *test, struct ml_options *opt, struct ml_model *model, int16_t fid)\n+{\n+\tstruct test_common *t = ml_test_priv(test);\n+\tint ret;\n+\n+\tRTE_SET_USED(t);\n+\n+\tif (model->state == MODEL_STARTED)\n+\t\treturn 0;\n+\n+\tif (model->state != MODEL_LOADED)\n+\t\treturn -EINVAL;\n+\n+\t/* start model */\n+\tret = rte_ml_model_start(opt->dev_id, model->id);\n+\tif (ret != 0) {\n+\t\tml_err(\"Failed to start model : %s\\n\", opt->filelist[fid].model);\n+\t\tmodel->state = MODEL_ERROR;\n+\t\treturn ret;\n+\t}\n+\n+\tmodel->state = MODEL_STARTED;\n+\n+\treturn 0;\n+}\n+\n+int\n+ml_model_stop(struct ml_test *test, struct ml_options *opt, struct ml_model *model, int16_t fid)\n+{\n+\tstruct test_common *t = ml_test_priv(test);\n+\tint ret;\n+\n+\tRTE_SET_USED(t);\n+\n+\tif (model->state == MODEL_LOADED)\n+\t\treturn 0;\n+\n+\tif (model->state != MODEL_STARTED)\n+\t\treturn -EINVAL;\n+\n+\t/* stop model */\n+\tret = rte_ml_model_stop(opt->dev_id, model->id);\n+\tif (ret != 0) {\n+\t\tml_err(\"Failed to stop model: %s\\n\", opt->filelist[fid].model);\n+\t\tmodel->state = MODEL_ERROR;\n+\t\treturn ret;\n+\t}\n+\n+\tmodel->state = MODEL_LOADED;\n+\n+\treturn 0;\n+}\ndiff --git a/app/test-mldev/test_model_common.h b/app/test-mldev/test_model_common.h\nnew file mode 100644\nindex 0000000000..302e4eb45f\n--- /dev/null\n+++ b/app/test-mldev/test_model_common.h\n@@ -0,0 +1,37 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2022 Marvell.\n+ */\n+\n+#ifndef _ML_TEST_MODEL_COMMON_\n+#define _ML_TEST_MODEL_COMMON_\n+\n+#include <stdint.h>\n+\n+#include <rte_mldev.h>\n+\n+#include \"ml_options.h\"\n+#include \"ml_test.h\"\n+\n+enum model_state {\n+\tMODEL_INITIAL,\n+\tMODEL_LOADED,\n+\tMODEL_STARTED,\n+\tMODEL_ERROR,\n+};\n+\n+struct ml_model {\n+\tint16_t id;\n+\tstruct rte_ml_model_info info;\n+\tenum model_state state;\n+};\n+\n+int ml_model_load(struct ml_test *test, struct ml_options *opt, struct ml_model *model,\n+\t\t int16_t fid);\n+int ml_model_unload(struct ml_test *test, struct ml_options *opt, struct ml_model *model,\n+\t\t int16_t fid);\n+int ml_model_start(struct ml_test *test, struct ml_options *opt, struct ml_model *model,\n+\t\t int16_t fid);\n+int ml_model_stop(struct ml_test *test, struct ml_options *opt, struct ml_model *model,\n+\t\t int16_t fid);\n+\n+#endif /* _ML_TEST_MODEL_COMMON_ */\ndiff --git a/app/test-mldev/test_model_ops.c b/app/test-mldev/test_model_ops.c\nnew file mode 100644\nindex 0000000000..69c9df8ed6\n--- /dev/null\n+++ b/app/test-mldev/test_model_ops.c\n@@ -0,0 +1,433 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2022 Marvell.\n+ */\n+\n+#include <stdint.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+\n+#include <rte_common.h>\n+#include <rte_malloc.h>\n+#include <rte_mldev.h>\n+\n+#include \"ml_common.h\"\n+#include \"ml_options.h\"\n+#include \"ml_test.h\"\n+#include \"test_model_ops.h\"\n+\n+static bool\n+test_model_ops_cap_check(struct ml_options *opt)\n+{\n+\tif (!ml_test_cap_check(opt))\n+\t\treturn false;\n+\n+\treturn true;\n+}\n+\n+static int\n+test_model_ops_opt_check(struct ml_options *opt)\n+{\n+\tuint32_t i;\n+\tint ret;\n+\n+\t/* check common opts */\n+\tret = ml_test_opt_check(opt);\n+\tif (ret != 0)\n+\t\treturn ret;\n+\n+\t/* check model file availability */\n+\tfor (i = 0; i < opt->nb_filelist; i++) {\n+\t\tif (access(opt->filelist[i].model, F_OK) == -1) {\n+\t\t\tml_err(\"Model file not available: id = %u, file = %s\", i,\n+\t\t\t opt->filelist[i].model);\n+\t\t\treturn -ENOENT;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void\n+test_model_ops_opt_dump(struct ml_options *opt)\n+{\n+\tuint32_t i;\n+\n+\t/* dump common opts */\n+\tml_test_opt_dump(opt);\n+\n+\t/* dump test specific opts */\n+\tml_dump_begin(\"models\");\n+\tfor (i = 0; i < opt->nb_filelist; i++)\n+\t\tml_dump_list(\"model\", i, opt->filelist[i].model);\n+\tml_dump_end;\n+}\n+\n+static int\n+test_model_ops_setup(struct ml_test *test, struct ml_options *opt)\n+{\n+\tstruct test_model_ops *t;\n+\tvoid *test_model_ops;\n+\tint ret = 0;\n+\tuint32_t i;\n+\n+\t/* allocate model ops test structure */\n+\ttest_model_ops = rte_zmalloc_socket(test->name, sizeof(struct test_model_ops),\n+\t\t\t\t\t RTE_CACHE_LINE_SIZE, opt->socket_id);\n+\tif (test_model_ops == NULL) {\n+\t\tml_err(\"Failed to allocate memory for test_model\");\n+\t\tret = -ENOMEM;\n+\t\tgoto error;\n+\t}\n+\ttest->test_priv = test_model_ops;\n+\tt = ml_test_priv(test);\n+\n+\tt->cmn.result = ML_TEST_FAILED;\n+\tt->cmn.opt = opt;\n+\n+\t/* get device info */\n+\tret = rte_ml_dev_info_get(opt->dev_id, &t->cmn.dev_info);\n+\tif (ret < 0) {\n+\t\tml_err(\"Failed to get device info\");\n+\t\tgoto error;\n+\t}\n+\n+\t/* set model initial state */\n+\tfor (i = 0; i < opt->nb_filelist; i++)\n+\t\tt->model[i].state = MODEL_INITIAL;\n+\n+\treturn 0;\n+\n+error:\n+\tif (test_model_ops != NULL)\n+\t\trte_free(test_model_ops);\n+\n+\treturn ret;\n+}\n+\n+static void\n+test_model_ops_destroy(struct ml_test *test, struct ml_options *opt)\n+{\n+\tstruct test_model_ops *t;\n+\n+\tRTE_SET_USED(opt);\n+\n+\tt = ml_test_priv(test);\n+\tif (t != NULL)\n+\t\trte_free(t);\n+}\n+\n+static int\n+test_model_ops_mldev_setup(struct ml_test *test, struct ml_options *opt)\n+{\n+\tint ret;\n+\n+\tret = ml_test_device_configure(test, opt);\n+\tif (ret != 0)\n+\t\treturn ret;\n+\n+\tret = ml_test_device_start(test, opt);\n+\tif (ret != 0)\n+\t\tgoto error;\n+\n+\treturn 0;\n+\n+error:\n+\tml_test_device_close(test, opt);\n+\n+\treturn ret;\n+}\n+\n+static int\n+test_model_ops_mldev_destroy(struct ml_test *test, struct ml_options *opt)\n+{\n+\tint ret;\n+\n+\tret = ml_test_device_stop(test, opt);\n+\tif (ret != 0)\n+\t\tgoto error;\n+\n+\tret = ml_test_device_close(test, opt);\n+\tif (ret != 0)\n+\t\treturn ret;\n+\n+\treturn 0;\n+\n+error:\n+\tml_test_device_close(test, opt);\n+\n+\treturn ret;\n+}\n+\n+/* Sub-test A: (load -> start -> stop -> unload) x n */\n+static int\n+test_model_ops_subtest_a(struct ml_test *test, struct ml_options *opt)\n+{\n+\tstruct test_model_ops *t;\n+\tint ret = 0;\n+\tuint32_t i;\n+\n+\tt = ml_test_priv(test);\n+\n+\t/* load + start + stop + unload */\n+\tfor (i = 0; i < opt->nb_filelist; i++) {\n+\t\tret = ml_model_load(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\n+\t\tret = ml_model_start(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\n+\t\tret = ml_model_stop(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\n+\t\tret = ml_model_unload(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\t}\n+\n+error:\n+\tfor (i = 0; i < opt->nb_filelist; i++)\n+\t\tml_model_stop(test, opt, &t->model[i], i);\n+\n+\tfor (i = 0; i < opt->nb_filelist; i++)\n+\t\tml_model_unload(test, opt, &t->model[i], i);\n+\n+\treturn ret;\n+}\n+\n+/* Sub-test B: load x n -> start x n -> stop x n -> unload x n */\n+static int\n+test_model_ops_subtest_b(struct ml_test *test, struct ml_options *opt)\n+{\n+\tstruct test_model_ops *t;\n+\tint ret = 0;\n+\tuint32_t i;\n+\n+\tt = ml_test_priv(test);\n+\n+\t/* load */\n+\tfor (i = 0; i < opt->nb_filelist; i++) {\n+\t\tret = ml_model_load(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\t}\n+\n+\t/* start */\n+\tfor (i = 0; i < opt->nb_filelist; i++) {\n+\t\tret = ml_model_start(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\t}\n+\n+\t/* stop */\n+\tfor (i = 0; i < opt->nb_filelist; i++) {\n+\t\tret = ml_model_stop(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\t}\n+\n+\t/* unload */\n+\tfor (i = 0; i < opt->nb_filelist; i++) {\n+\t\tret = ml_model_unload(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\t}\n+\n+\treturn 0;\n+\n+error:\n+\tfor (i = 0; i < opt->nb_filelist; i++)\n+\t\tml_model_stop(test, opt, &t->model[i], i);\n+\n+\tfor (i = 0; i < opt->nb_filelist; i++)\n+\t\tml_model_unload(test, opt, &t->model[i], i);\n+\n+\treturn ret;\n+}\n+\n+/* Sub-test C: load x n + (start + stop) x n + unload x n */\n+static int\n+test_model_ops_subtest_c(struct ml_test *test, struct ml_options *opt)\n+{\n+\tstruct test_model_ops *t;\n+\tint ret = 0;\n+\tuint32_t i;\n+\n+\tt = ml_test_priv(test);\n+\n+\t/* load */\n+\tfor (i = 0; i < opt->nb_filelist; i++) {\n+\t\tret = ml_model_load(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\t}\n+\n+\t/* start + stop */\n+\tfor (i = 0; i < opt->nb_filelist; i++) {\n+\t\tret = ml_model_start(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\n+\t\tret = ml_model_stop(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\t}\n+\n+\t/* unload */\n+\tfor (i = 0; i < opt->nb_filelist; i++) {\n+\t\tret = ml_model_unload(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\t}\n+\n+\treturn 0;\n+\n+error:\n+\tfor (i = 0; i < opt->nb_filelist; i++)\n+\t\tml_model_stop(test, opt, &t->model[i], i);\n+\n+\tfor (i = 0; i < opt->nb_filelist; i++)\n+\t\tml_model_unload(test, opt, &t->model[i], i);\n+\n+\treturn ret;\n+}\n+\n+/* Sub-test D: (load + start) x n -> (stop + unload) x n */\n+static int\n+test_model_ops_subtest_d(struct ml_test *test, struct ml_options *opt)\n+{\n+\tstruct test_model_ops *t;\n+\tint ret = 0;\n+\tuint32_t i;\n+\n+\tt = ml_test_priv(test);\n+\n+\t/* load + start */\n+\tfor (i = 0; i < opt->nb_filelist; i++) {\n+\t\tret = ml_model_load(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\n+\t\tret = ml_model_start(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\t}\n+\n+\t/* stop + unload */\n+\tfor (i = 0; i < opt->nb_filelist; i++) {\n+\t\tret = ml_model_stop(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\n+\t\tret = ml_model_unload(test, opt, &t->model[i], i);\n+\t\tif (ret != 0)\n+\t\t\tgoto error;\n+\t}\n+\n+\treturn 0;\n+\n+error:\n+\tfor (i = 0; i < opt->nb_filelist; i++)\n+\t\tml_model_stop(test, opt, &t->model[i], i);\n+\n+\tfor (i = 0; i < opt->nb_filelist; i++)\n+\t\tml_model_unload(test, opt, &t->model[i], i);\n+\n+\treturn ret;\n+}\n+\n+static int\n+test_model_ops_driver(struct ml_test *test, struct ml_options *opt)\n+{\n+\tstruct test_model_ops *t;\n+\tint ret = 0;\n+\n+\tt = ml_test_priv(test);\n+\n+\t/* device setup */\n+\tret = test_model_ops_mldev_setup(test, opt);\n+\tif (ret != 0)\n+\t\treturn ret;\n+\n+\tprintf(\"\\n\");\n+\n+\t/* sub-test A */\n+\tret = test_model_ops_subtest_a(test, opt);\n+\tif (ret != 0) {\n+\t\tprintf(\"Model Ops Sub-test A: \" CLRED \"%s\" CLNRM \"\\n\", \"Failed\");\n+\t\tgoto error;\n+\t} else {\n+\t\tprintf(\"Model Ops Sub-test A: \" CLYEL \"%s\" CLNRM \"\\n\", \"Passed\");\n+\t}\n+\n+\t/* sub-test B */\n+\tret = test_model_ops_subtest_b(test, opt);\n+\tif (ret != 0) {\n+\t\tprintf(\"Model Ops Sub-test B: \" CLRED \"%s\" CLNRM \"\\n\", \"Failed\");\n+\t\tgoto error;\n+\t} else {\n+\t\tprintf(\"Model Ops Sub-test B: \" CLYEL \"%s\" CLNRM \"\\n\", \"Passed\");\n+\t}\n+\n+\t/* sub-test C */\n+\tret = test_model_ops_subtest_c(test, opt);\n+\tif (ret != 0) {\n+\t\tprintf(\"Model Ops Sub-test C: \" CLRED \"%s\" CLNRM \"\\n\", \"Failed\");\n+\t\tgoto error;\n+\t} else {\n+\t\tprintf(\"Model Ops Sub-test C: \" CLYEL \"%s\" CLNRM \"\\n\", \"Passed\");\n+\t}\n+\n+\t/* sub-test D */\n+\tret = test_model_ops_subtest_d(test, opt);\n+\tif (ret != 0) {\n+\t\tprintf(\"Model Ops Sub-test D: \" CLRED \"%s\" CLNRM \"\\n\", \"Failed\");\n+\t\tgoto error;\n+\t} else {\n+\t\tprintf(\"Model Ops Sub-test D: \" CLYEL \"%s\" CLNRM \"\\n\", \"Passed\");\n+\t}\n+\n+\tprintf(\"\\n\");\n+\n+\t/* device destroy */\n+\tret = test_model_ops_mldev_destroy(test, opt);\n+\tif (ret != 0)\n+\t\treturn ret;\n+\n+\tt->cmn.result = ML_TEST_SUCCESS;\n+\n+\treturn 0;\n+\n+error:\n+\ttest_model_ops_mldev_destroy(test, opt);\n+\n+\tt->cmn.result = ML_TEST_FAILED;\n+\n+\treturn ret;\n+}\n+\n+static int\n+test_model_ops_result(struct ml_test *test, struct ml_options *opt)\n+{\n+\tstruct test_model_ops *t;\n+\n+\tRTE_SET_USED(opt);\n+\n+\tt = ml_test_priv(test);\n+\n+\treturn t->cmn.result;\n+}\n+\n+static const struct ml_test_ops model_ops = {\n+\t.cap_check = test_model_ops_cap_check,\n+\t.opt_check = test_model_ops_opt_check,\n+\t.opt_dump = test_model_ops_opt_dump,\n+\t.test_setup = test_model_ops_setup,\n+\t.test_destroy = test_model_ops_destroy,\n+\t.test_driver = test_model_ops_driver,\n+\t.test_result = test_model_ops_result,\n+};\n+\n+ML_TEST_REGISTER(model_ops);\ndiff --git a/app/test-mldev/test_model_ops.h b/app/test-mldev/test_model_ops.h\nnew file mode 100644\nindex 0000000000..9dd8402390\n--- /dev/null\n+++ b/app/test-mldev/test_model_ops.h\n@@ -0,0 +1,21 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2022 Marvell.\n+ */\n+\n+#ifndef _ML_TEST_MODEL_OPS_\n+#define _ML_TEST_MODEL_OPS_\n+\n+#include <rte_common.h>\n+\n+#include \"test_common.h\"\n+#include \"test_model_common.h\"\n+\n+struct test_model_ops {\n+\t/* common data */\n+\tstruct test_common cmn;\n+\n+\t/* test specific data */\n+\tstruct ml_model model[ML_TEST_MAX_MODELS];\n+} __rte_cache_aligned;\n+\n+#endif /* _ML_TEST_MODEL_OPS_ */\n", "prefixes": [ "v3", "04/12" ] }{ "id": 120586, "url": "