get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/130901/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 130901,
    "url": "http://patchwork.dpdk.org/api/patches/130901/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230830155927.3566-24-syalavarthi@marvell.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<20230830155927.3566-24-syalavarthi@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230830155927.3566-24-syalavarthi@marvell.com",
    "date": "2023-08-30T15:59:13",
    "name": "[v1,23/34] ml/cnxk: fetch layer info and load TVM model",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "cd1e2b1d194de64d5ef2450e731341262c3062a2",
    "submitter": {
        "id": 2480,
        "url": "http://patchwork.dpdk.org/api/people/2480/?format=api",
        "name": "Srikanth Yalavarthi",
        "email": "syalavarthi@marvell.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230830155927.3566-24-syalavarthi@marvell.com/mbox/",
    "series": [
        {
            "id": 29376,
            "url": "http://patchwork.dpdk.org/api/series/29376/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29376",
            "date": "2023-08-30T15:58:50",
            "name": "Implemenation of revised ml/cnxk driver",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/29376/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/130901/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/130901/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 0CF7141FD1;\n\tWed, 30 Aug 2023 18:04:01 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id EC94E40E72;\n\tWed, 30 Aug 2023 18:00:01 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173])\n by mails.dpdk.org (Postfix) with ESMTP id E5F66402B4\n for <dev@dpdk.org>; Wed, 30 Aug 2023 17:59:41 +0200 (CEST)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 37U86I73012554 for <dev@dpdk.org>; Wed, 30 Aug 2023 08:59:41 -0700",
            "from dc5-exch01.marvell.com ([199.233.59.181])\n by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3st1y61ga5-12\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Wed, 30 Aug 2023 08:59:41 -0700",
            "from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48;\n Wed, 30 Aug 2023 08:59:39 -0700",
            "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.48 via Frontend\n Transport; Wed, 30 Aug 2023 08:59:39 -0700",
            "from ml-host-33.caveonetworks.com (unknown [10.110.143.233])\n by maili.marvell.com (Postfix) with ESMTP id B9C483F707F;\n Wed, 30 Aug 2023 08:59:39 -0700 (PDT)"
        ],
        "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-transfer-encoding : content-type; s=pfpt0220;\n bh=uudmush/oxpbGoH/zjziUY1/QqqLDF9rBkKwNIqZ62Y=;\n b=PRLeblUIhrNET0K01cQGU6/BXBBjttPlkUnjC7hL/+Q+kn4zgeI9BT7SMJoV4pyTHUvy\n Nyi2L4S/yOVVdsnHmbf0xHM+zuauVi9mG7+ywmKfnKtrx4qNJnBe+SP7h1tov+MpM80e\n xGVbaSLkCVerWBBo3b6GgQTHmDKzV+jocZg0EsjYx70tcMA0I4/BVltjIvDIPmpmM+GV\n nyFNfZ627iYDZ8rfrKvwBHNTR9Dozp3MNwgbyDfSp12ZanXZtHYBTv/DforEFKqI0wm2\n SSgBOzlrg6FOiFf2cr5KPIdWi21teCQcxrctntturhZoX3+yWlIqZlNpGB5jNDvqI7US qg==",
        "From": "Srikanth Yalavarthi <syalavarthi@marvell.com>",
        "To": "Srikanth Yalavarthi <syalavarthi@marvell.com>",
        "CC": "<dev@dpdk.org>, <sshankarnara@marvell.com>, <aprabhu@marvell.com>,\n <ptakkar@marvell.com>",
        "Subject": "[PATCH v1 23/34] ml/cnxk: fetch layer info and load TVM model",
        "Date": "Wed, 30 Aug 2023 08:59:13 -0700",
        "Message-ID": "<20230830155927.3566-24-syalavarthi@marvell.com>",
        "X-Mailer": "git-send-email 2.41.0",
        "In-Reply-To": "<20230830155927.3566-1-syalavarthi@marvell.com>",
        "References": "<20230830155927.3566-1-syalavarthi@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-ORIG-GUID": "PTWUBdskfr4dXRHYnogCMAu-mWVCPC1o",
        "X-Proofpoint-GUID": "PTWUBdskfr4dXRHYnogCMAu-mWVCPC1o",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26\n definitions=2023-08-30_12,2023-08-29_01,2023-05-22_02",
        "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 support to fetch TVM model layer information and\nupdate internal structures based on the layer information\nSet callback functions for layer load and unload and\nenable model loading using TVMDP library. Added support\nto fetch full metadata after model load.\n\nSigned-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>\n---\n drivers/ml/cnxk/cn10k_ml_ops.c   | 22 ++++++++-\n drivers/ml/cnxk/mvtvm_ml_model.h |  2 +\n drivers/ml/cnxk/mvtvm_ml_ops.c   | 83 ++++++++++++++++++++++++++++++++\n 3 files changed, 106 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/ml/cnxk/cn10k_ml_ops.c b/drivers/ml/cnxk/cn10k_ml_ops.c\nindex db18f320527..79217165cd5 100644\n--- a/drivers/ml/cnxk/cn10k_ml_ops.c\n+++ b/drivers/ml/cnxk/cn10k_ml_ops.c\n@@ -508,8 +508,10 @@ cn10k_ml_layer_load(void *device, uint16_t model_id, const char *layer_name, uin\n \tint qp_id;\n \tint ret;\n \n-\tPLT_SET_USED(size);\n+#ifndef RTE_MLDEV_CNXK_ENABLE_MVTVM\n \tPLT_SET_USED(layer_name);\n+#endif\n+\tPLT_SET_USED(size);\n \n \tcnxk_mldev = (struct cnxk_ml_dev *)device;\n \tif (cnxk_mldev == NULL) {\n@@ -523,6 +525,24 @@ cn10k_ml_layer_load(void *device, uint16_t model_id, const char *layer_name, uin\n \t\treturn -EINVAL;\n \t}\n \n+#ifdef RTE_MLDEV_CNXK_ENABLE_MVTVM\n+\tif (model->type == ML_CNXK_MODEL_TYPE_TVM) {\n+\t\tfor (layer_id = 0; layer_id < model->mvtvm.metadata.model.nb_layers; layer_id++) {\n+\t\t\tif (strcmp(model->layer[layer_id].name, layer_name) == 0)\n+\t\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (layer_id == model->mvtvm.metadata.model.nb_layers) {\n+\t\t\tplt_err(\"Invalid layer name: %s\", layer_name);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tif (model->layer[layer_id].type != ML_CNXK_LAYER_TYPE_MRVL) {\n+\t\t\tplt_err(\"Invalid layer name / type: %s\", layer_name);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+#endif\n \tlayer = &model->layer[layer_id];\n \n \tret = cn10k_ml_model_metadata_check(buffer, size);\ndiff --git a/drivers/ml/cnxk/mvtvm_ml_model.h b/drivers/ml/cnxk/mvtvm_ml_model.h\nindex 73a45a91d66..6c38217c158 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_model.h\n+++ b/drivers/ml/cnxk/mvtvm_ml_model.h\n@@ -11,6 +11,8 @@\n \n #include \"cnxk_ml_io.h\"\n \n+struct cnxk_ml_model;\n+\n /* Maximum number of objects per model */\n #define ML_MVTVM_MODEL_OBJECT_MAX 3\n \ndiff --git a/drivers/ml/cnxk/mvtvm_ml_ops.c b/drivers/ml/cnxk/mvtvm_ml_ops.c\nindex 1bdd4515771..5c30bbf6b89 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_ops.c\n+++ b/drivers/ml/cnxk/mvtvm_ml_ops.c\n@@ -9,6 +9,8 @@\n #include <rte_mldev.h>\n #include <rte_mldev_pmd.h>\n \n+#include \"cn10k_ml_ops.h\"\n+\n #include \"mvtvm_ml_model.h\"\n #include \"mvtvm_ml_ops.h\"\n \n@@ -53,9 +55,13 @@ mvtvm_ml_model_load(struct cnxk_ml_dev *cnxk_mldev, struct rte_ml_model_params *\n \t\t    struct cnxk_ml_model *model)\n {\n \tstruct mvtvm_ml_model_object object[ML_MVTVM_MODEL_OBJECT_MAX];\n+\tstruct tvmrt_glow_callback *callback;\n \tchar str[RTE_MEMZONE_NAMESIZE];\n \tconst struct plt_memzone *mz;\n \tsize_t model_object_size = 0;\n+\tuint16_t nb_mrvl_layers;\n+\tuint16_t nb_llvm_layers;\n+\tuint8_t layer_id = 0;\n \tuint64_t mz_size = 0;\n \tint ret;\n \n@@ -103,5 +109,82 @@ mvtvm_ml_model_load(struct cnxk_ml_dev *cnxk_mldev, struct rte_ml_model_params *\n \trte_memcpy(model->mvtvm.object.params.addr, object[2].buffer, object[2].size);\n \trte_free(object[2].buffer);\n \n+\t/* Get metadata - stage 1 */\n+\tret = tvmdp_model_metadata_get_stage1(model->mvtvm.object.json.addr,\n+\t\t\t\t\t      model->mvtvm.object.json.size,\n+\t\t\t\t\t      &model->mvtvm.metadata);\n+\tif (ret != 0) {\n+\t\tplt_err(\"TVMDP: Failed to parse metadata - stage 1, model_id = %u, error = %d\",\n+\t\t\tmodel->model_id, ret);\n+\t\tgoto error;\n+\t}\n+\n+\t/* Set model fields */\n+\tplt_strlcpy(model->name, model->mvtvm.metadata.model.name, TVMDP_NAME_STRLEN);\n+\tmodel->batch_size = 1;\n+\tmodel->nb_layers = model->mvtvm.metadata.model.nb_layers;\n+\n+\t/* Update layer info */\n+\tnb_mrvl_layers = 0;\n+\tnb_llvm_layers = 0;\n+\tfor (layer_id = 0; layer_id < model->mvtvm.metadata.model.nb_layers; layer_id++) {\n+\t\tstrncpy(model->layer[layer_id].name,\n+\t\t\tmodel->mvtvm.metadata.model.layer[layer_id].name, TVMDP_NAME_STRLEN);\n+\t\tif (strcmp(model->mvtvm.metadata.model.layer[layer_id].type, \"mrvl\") == 0 ||\n+\t\t    strcmp(model->mvtvm.metadata.model.layer[layer_id].type, \"MRVL\") == 0) {\n+\t\t\tmodel->layer[layer_id].type = ML_CNXK_LAYER_TYPE_MRVL;\n+\t\t\tnb_mrvl_layers++;\n+\t\t} else if (strcmp(model->mvtvm.metadata.model.layer[layer_id].type, \"llvm\") == 0 ||\n+\t\t\t   strcmp(model->mvtvm.metadata.model.layer[layer_id].type, \"LLVM\") == 0) {\n+\t\t\tmodel->layer[layer_id].type = ML_CNXK_LAYER_TYPE_LLVM;\n+\t\t\tnb_llvm_layers++;\n+\t\t}\n+\t}\n+\n+\tif ((nb_llvm_layers == 0) && (nb_mrvl_layers == 0)) {\n+\t\tplt_err(\"Invalid model, nb_llvm_layers = %u, nb_mrvl_layers = %u\", nb_llvm_layers,\n+\t\t\tnb_mrvl_layers);\n+\t\tgoto error;\n+\t}\n+\n+\t/* Set model subtype */\n+\tif ((nb_llvm_layers == 0) && (nb_mrvl_layers == 1))\n+\t\tmodel->subtype = ML_CNXK_MODEL_SUBTYPE_TVM_MRVL;\n+\telse if ((nb_llvm_layers > 0) && (nb_mrvl_layers == 0))\n+\t\tmodel->subtype = ML_CNXK_MODEL_SUBTYPE_TVM_LLVM;\n+\telse\n+\t\tmodel->subtype = ML_CNXK_MODEL_SUBTYPE_TVM_HYBRID;\n+\n+\t/* Set callback function array */\n+\tif (model->subtype != ML_CNXK_MODEL_SUBTYPE_TVM_LLVM) {\n+\t\tcallback = &model->mvtvm.cb;\n+\t\tcallback->tvmrt_glow_layer_load = cn10k_ml_layer_load;\n+\t\tcallback->tvmrt_glow_layer_unload = cn10k_ml_layer_unload;\n+\t} else {\n+\t\tcallback = NULL;\n+\t}\n+\n+\t/* Initialize model in TVMDP */\n+\tret = tvmdp_model_load(cnxk_mldev, model->model_id, (void *)(&model->mvtvm.object),\n+\t\t\t       callback);\n+\tif (ret != 0) {\n+\t\tplt_err(\"TVMDP: Model load failed, model_id = %u, error = %d\", model->model_id,\n+\t\t\tret);\n+\t\tgoto error;\n+\t}\n+\n+\t/* Get model metadata - stage 2 */\n+\tret = tvmdp_model_metadata_get_stage2(model->model_id, &model->mvtvm.metadata);\n+\tif (ret != 0) {\n+\t\tplt_err(\"TVMDP: Failed to get metadata, model_id = %u, error = %d\\n\",\n+\t\t\tmodel->model_id, ret);\n+\t\tgoto error;\n+\t}\n+\n \treturn 0;\n+\n+error:\n+\trte_memzone_free(mz);\n+\n+\treturn ret;\n }\n",
    "prefixes": [
        "v1",
        "23/34"
    ]
}