get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 132953,
    "url": "http://patches.dpdk.org/api/patches/132953/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20231019041726.19243-22-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": "<20231019041726.19243-22-syalavarthi@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20231019041726.19243-22-syalavarthi@marvell.com",
    "date": "2023-10-19T04:17:10",
    "name": "[v7,21/34] ml/cnxk: add support to parse TVM model objects",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "ee87aea9cc2f0a099737460f325d80f64c9981b2",
    "submitter": {
        "id": 2480,
        "url": "http://patches.dpdk.org/api/people/2480/?format=api",
        "name": "Srikanth Yalavarthi",
        "email": "syalavarthi@marvell.com"
    },
    "delegate": {
        "id": 310,
        "url": "http://patches.dpdk.org/api/users/310/?format=api",
        "username": "jerin",
        "first_name": "Jerin",
        "last_name": "Jacob",
        "email": "jerinj@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20231019041726.19243-22-syalavarthi@marvell.com/mbox/",
    "series": [
        {
            "id": 29913,
            "url": "http://patches.dpdk.org/api/series/29913/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=29913",
            "date": "2023-10-19T04:16:49",
            "name": "Implementation of revised ml/cnxk driver",
            "version": 7,
            "mbox": "http://patches.dpdk.org/series/29913/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/132953/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/132953/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 03547431A4;\n\tThu, 19 Oct 2023 06:20:33 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 4A1B542E0A;\n\tThu, 19 Oct 2023 06:17:59 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174])\n by mails.dpdk.org (Postfix) with ESMTP id A7C1640279\n for <dev@dpdk.org>; Thu, 19 Oct 2023 06:17:38 +0200 (CEST)",
            "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 39J01WvC008136 for <dev@dpdk.org>; Wed, 18 Oct 2023 21:17:37 -0700",
            "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3ttshu8rva-15\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Wed, 18 Oct 2023 21:17:37 -0700",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48;\n Wed, 18 Oct 2023 21:17:35 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend\n Transport; Wed, 18 Oct 2023 21:17:35 -0700",
            "from ml-host-33.caveonetworks.com (unknown [10.110.143.233])\n by maili.marvell.com (Postfix) with ESMTP id D22455B6928;\n Wed, 18 Oct 2023 21:17:35 -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=lwJ4mtSTpXPFT4h1yi0+Q1f96FBAU4q0f77FTPxcY7A=;\n b=dKmFGF8HUJyJoNJI3eiJPQrZpHF8aQ18LxOAZIH0Yla86sM7uc9w7pm+bgp7g6aOWAy6\n Rn11ltrSpj6FAIjKNbYk22x/tD0P6CMT/DqxHwXIGaUjpm1yoiV5mkqUqvGT8LcANys3\n 38kQwdhu2giZyCy2KT0DN47KRgml9ByoGBE6NgS6azo0/hakfRBDFTHODycMmvoTe5lZ\n Ih6g10cUjGsojtkg8veGEioUGmIPie8/qiNwcOMqsNUUTFYJtHM3TlbI4zM7EDfnph7i\n IHjujJZXUGh7L61Xhcd/A1ALurp3I6ID5gcHHKX0ziK5dJuDmf+GbhfDIpnBWoJOrYDq hQ==",
        "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 v7 21/34] ml/cnxk: add support to parse TVM model objects",
        "Date": "Wed, 18 Oct 2023 21:17:10 -0700",
        "Message-ID": "<20231019041726.19243-22-syalavarthi@marvell.com>",
        "X-Mailer": "git-send-email 2.42.0",
        "In-Reply-To": "<20231019041726.19243-1-syalavarthi@marvell.com>",
        "References": "<20230830155927.3566-1-syalavarthi@marvell.com>\n <20231019041726.19243-1-syalavarthi@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "k8DFOht1tFIxXvmEbzF-0hiN-SwRYMO_",
        "X-Proofpoint-ORIG-GUID": "k8DFOht1tFIxXvmEbzF-0hiN-SwRYMO_",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26\n definitions=2023-10-19_02,2023-10-18_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 parse TVM model objects from the model\narchive buffer. Added support to check for all expected\nobjects and copy TVM model objects to internal buffers.\n\nSigned-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>\nSigned-off-by: Anup Prabhu <aprabhu@marvell.com>\n---\n drivers/ml/cnxk/cnxk_ml_ops.c    |  5 ++-\n drivers/ml/cnxk/mvtvm_ml_model.c | 57 +++++++++++++++++++++++++++++\n drivers/ml/cnxk/mvtvm_ml_model.h |  2 ++\n drivers/ml/cnxk/mvtvm_ml_ops.c   | 62 ++++++++++++++++++++++++++++++++\n drivers/ml/cnxk/mvtvm_ml_ops.h   |  3 ++\n drivers/ml/cnxk/mvtvm_ml_stubs.c | 11 ++++++\n drivers/ml/cnxk/mvtvm_ml_stubs.h |  3 ++\n 7 files changed, 142 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/ml/cnxk/cnxk_ml_ops.c b/drivers/ml/cnxk/cnxk_ml_ops.c\nindex ebc78e36e9..85b37161d2 100644\n--- a/drivers/ml/cnxk/cnxk_ml_ops.c\n+++ b/drivers/ml/cnxk/cnxk_ml_ops.c\n@@ -1079,7 +1079,10 @@ cnxk_ml_model_load(struct rte_ml_dev *dev, struct rte_ml_model_params *params, u\n \t\tmodel, PLT_ALIGN_CEIL(sizeof(struct cnxk_ml_model), dev_info.align_size));\n \tdev->data->models[lcl_model_id] = model;\n \n-\tret = cn10k_ml_model_load(cnxk_mldev, params, model);\n+\tif (type == ML_CNXK_MODEL_TYPE_GLOW)\n+\t\tret = cn10k_ml_model_load(cnxk_mldev, params, model);\n+\telse\n+\t\tret = mvtvm_ml_model_load(cnxk_mldev, params, model);\n \tif (ret != 0)\n \t\tgoto error;\n \ndiff --git a/drivers/ml/cnxk/mvtvm_ml_model.c b/drivers/ml/cnxk/mvtvm_ml_model.c\nindex ab5f8baa67..4c9a080c05 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_model.c\n+++ b/drivers/ml/cnxk/mvtvm_ml_model.c\n@@ -53,3 +53,60 @@ mvtvm_ml_model_type_get(struct rte_ml_model_params *params)\n \n \treturn ML_CNXK_MODEL_TYPE_TVM;\n }\n+\n+int\n+mvtvm_ml_model_blob_parse(struct rte_ml_model_params *params, struct mvtvm_ml_model_object *object)\n+{\n+\tbool object_found[ML_MVTVM_MODEL_OBJECT_MAX] = {false, false, false};\n+\tstruct archive_entry *entry;\n+\tstruct archive *a;\n+\tuint8_t i;\n+\tint ret;\n+\n+\t/* Open archive */\n+\ta = archive_read_new();\n+\tarchive_read_support_filter_all(a);\n+\tarchive_read_support_format_all(a);\n+\n+\tret = archive_read_open_memory(a, params->addr, params->size);\n+\tif (ret != ARCHIVE_OK)\n+\t\treturn archive_errno(a);\n+\n+\t/* Read archive */\n+\twhile (archive_read_next_header(a, &entry) == ARCHIVE_OK) {\n+\t\tfor (i = 0; i < ML_MVTVM_MODEL_OBJECT_MAX; i++) {\n+\t\t\tif (!object_found[i] &&\n+\t\t\t    (strcmp(archive_entry_pathname(entry), mvtvm_object_list[i]) == 0)) {\n+\t\t\t\tmemcpy(object[i].name, mvtvm_object_list[i], RTE_ML_STR_MAX);\n+\t\t\t\tobject[i].size = archive_entry_size(entry);\n+\t\t\t\tobject[i].buffer = rte_malloc(NULL, object[i].size, 0);\n+\n+\t\t\t\tif (archive_read_data(a, object[i].buffer, object[i].size) !=\n+\t\t\t\t    object[i].size) {\n+\t\t\t\t\tplt_err(\"Failed to read object from model archive: %s\",\n+\t\t\t\t\t\tobject[i].name);\n+\t\t\t\t\tgoto error;\n+\t\t\t\t}\n+\t\t\t\tobject_found[i] = true;\n+\t\t\t}\n+\t\t}\n+\t\tarchive_read_data_skip(a);\n+\t}\n+\n+\t/* Check if all objects are parsed */\n+\tfor (i = 0; i < ML_MVTVM_MODEL_OBJECT_MAX; i++) {\n+\t\tif (!object_found[i]) {\n+\t\t\tplt_err(\"Object %s not found in archive!\\n\", mvtvm_object_list[i]);\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\treturn 0;\n+\n+error:\n+\tfor (i = 0; i < ML_MVTVM_MODEL_OBJECT_MAX; i++) {\n+\t\tif (object[i].buffer != NULL)\n+\t\t\trte_free(object[i].buffer);\n+\t}\n+\n+\treturn -EINVAL;\n+}\ndiff --git a/drivers/ml/cnxk/mvtvm_ml_model.h b/drivers/ml/cnxk/mvtvm_ml_model.h\nindex b6162fceec..b11b66f495 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_model.h\n+++ b/drivers/ml/cnxk/mvtvm_ml_model.h\n@@ -44,5 +44,7 @@ struct mvtvm_ml_model_data {\n };\n \n enum cnxk_ml_model_type mvtvm_ml_model_type_get(struct rte_ml_model_params *params);\n+int mvtvm_ml_model_blob_parse(struct rte_ml_model_params *params,\n+\t\t\t      struct mvtvm_ml_model_object *object);\n \n #endif /* _MVTVM_ML_MODEL_H_ */\ndiff --git a/drivers/ml/cnxk/mvtvm_ml_ops.c b/drivers/ml/cnxk/mvtvm_ml_ops.c\nindex 88c6d5a864..e2413b6b15 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_ops.c\n+++ b/drivers/ml/cnxk/mvtvm_ml_ops.c\n@@ -8,8 +8,12 @@\n #include <rte_mldev_pmd.h>\n \n #include \"cnxk_ml_dev.h\"\n+#include \"cnxk_ml_model.h\"\n #include \"cnxk_ml_ops.h\"\n \n+/* ML model macros */\n+#define MVTVM_ML_MODEL_MEMZONE_NAME \"ml_mvtvm_model_mz\"\n+\n int\n mvtvm_ml_dev_configure(struct cnxk_ml_dev *cnxk_mldev, const struct rte_ml_dev_config *conf)\n {\n@@ -39,3 +43,61 @@ mvtvm_ml_dev_close(struct cnxk_ml_dev *cnxk_mldev)\n \n \treturn ret;\n }\n+\n+int\n+mvtvm_ml_model_load(struct cnxk_ml_dev *cnxk_mldev, struct rte_ml_model_params *params,\n+\t\t    struct cnxk_ml_model *model)\n+{\n+\tstruct mvtvm_ml_model_object object[ML_MVTVM_MODEL_OBJECT_MAX];\n+\tchar str[RTE_MEMZONE_NAMESIZE];\n+\tconst struct plt_memzone *mz;\n+\tsize_t model_object_size = 0;\n+\tuint64_t mz_size = 0;\n+\tint ret;\n+\n+\tRTE_SET_USED(cnxk_mldev);\n+\n+\tret = mvtvm_ml_model_blob_parse(params, object);\n+\tif (ret != 0)\n+\t\treturn ret;\n+\n+\tmodel_object_size = RTE_ALIGN_CEIL(object[0].size, RTE_CACHE_LINE_MIN_SIZE) +\n+\t\t\t    RTE_ALIGN_CEIL(object[1].size, RTE_CACHE_LINE_MIN_SIZE) +\n+\t\t\t    RTE_ALIGN_CEIL(object[2].size, RTE_CACHE_LINE_MIN_SIZE);\n+\tmz_size += model_object_size;\n+\n+\t/* Allocate memzone for model object */\n+\tsnprintf(str, RTE_MEMZONE_NAMESIZE, \"%s_%u\", MVTVM_ML_MODEL_MEMZONE_NAME, model->model_id);\n+\tmz = plt_memzone_reserve_aligned(str, mz_size, 0, ML_CN10K_ALIGN_SIZE);\n+\tif (!mz) {\n+\t\tplt_err(\"plt_memzone_reserve failed : %s\", str);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\t/* Copy mod.so */\n+\tmodel->mvtvm.object.so.addr = mz->addr;\n+\tmodel->mvtvm.object.so.size = object[0].size;\n+\trte_memcpy(model->mvtvm.object.so.name, object[0].name, TVMDP_NAME_STRLEN);\n+\trte_memcpy(model->mvtvm.object.so.addr, object[0].buffer, object[0].size);\n+\trte_free(object[0].buffer);\n+\n+\t/* Copy mod.json */\n+\tmodel->mvtvm.object.json.addr =\n+\t\tRTE_PTR_ADD(model->mvtvm.object.so.addr,\n+\t\t\t    RTE_ALIGN_CEIL(model->mvtvm.object.so.size, RTE_CACHE_LINE_MIN_SIZE));\n+\tmodel->mvtvm.object.json.size = object[1].size;\n+\trte_memcpy(model->mvtvm.object.json.name, object[1].name, TVMDP_NAME_STRLEN);\n+\trte_memcpy(model->mvtvm.object.json.addr, object[1].buffer, object[1].size);\n+\trte_free(object[1].buffer);\n+\n+\t/* Copy mod.params */\n+\tmodel->mvtvm.object.params.addr =\n+\t\tRTE_PTR_ADD(model->mvtvm.object.json.addr,\n+\t\t\t    RTE_ALIGN_CEIL(model->mvtvm.object.json.size, RTE_CACHE_LINE_MIN_SIZE));\n+\tmodel->mvtvm.object.params.size = object[2].size;\n+\trte_memcpy(model->mvtvm.object.params.name, object[2].name, TVMDP_NAME_STRLEN);\n+\trte_memcpy(model->mvtvm.object.params.addr, object[2].buffer, object[2].size);\n+\trte_free(object[2].buffer);\n+\n+\treturn 0;\n+}\ndiff --git a/drivers/ml/cnxk/mvtvm_ml_ops.h b/drivers/ml/cnxk/mvtvm_ml_ops.h\nindex 305b4681ed..6607537599 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_ops.h\n+++ b/drivers/ml/cnxk/mvtvm_ml_ops.h\n@@ -12,8 +12,11 @@\n #include <rte_mldev.h>\n \n struct cnxk_ml_dev;\n+struct cnxk_ml_model;\n \n int mvtvm_ml_dev_configure(struct cnxk_ml_dev *cnxk_mldev, const struct rte_ml_dev_config *conf);\n int mvtvm_ml_dev_close(struct cnxk_ml_dev *cnxk_mldev);\n+int mvtvm_ml_model_load(struct cnxk_ml_dev *cnxk_mldev, struct rte_ml_model_params *params,\n+\t\t\tstruct cnxk_ml_model *model);\n \n #endif /* _MVTVM_ML_OPS_H_ */\ndiff --git a/drivers/ml/cnxk/mvtvm_ml_stubs.c b/drivers/ml/cnxk/mvtvm_ml_stubs.c\nindex a7352840a6..7f3b3abb2e 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_stubs.c\n+++ b/drivers/ml/cnxk/mvtvm_ml_stubs.c\n@@ -33,3 +33,14 @@ mvtvm_ml_dev_close(struct cnxk_ml_dev *cnxk_mldev)\n \n \treturn 0;\n }\n+\n+int\n+mvtvm_ml_model_load(struct cnxk_ml_dev *cnxk_mldev, struct rte_ml_model_params *params,\n+\t\t    struct cnxk_ml_model *model)\n+{\n+\tRTE_SET_USED(cnxk_mldev);\n+\tRTE_SET_USED(params);\n+\tRTE_SET_USED(model);\n+\n+\treturn -EINVAL;\n+}\ndiff --git a/drivers/ml/cnxk/mvtvm_ml_stubs.h b/drivers/ml/cnxk/mvtvm_ml_stubs.h\nindex 467a9d39e5..4bb1772ef4 100644\n--- a/drivers/ml/cnxk/mvtvm_ml_stubs.h\n+++ b/drivers/ml/cnxk/mvtvm_ml_stubs.h\n@@ -8,9 +8,12 @@\n #include <rte_mldev.h>\n \n struct cnxk_ml_dev;\n+struct cnxk_ml_model;\n \n enum cnxk_ml_model_type mvtvm_ml_model_type_get(struct rte_ml_model_params *params);\n int mvtvm_ml_dev_configure(struct cnxk_ml_dev *cnxk_mldev, const struct rte_ml_dev_config *conf);\n int mvtvm_ml_dev_close(struct cnxk_ml_dev *cnxk_mldev);\n+int mvtvm_ml_model_load(struct cnxk_ml_dev *cnxk_mldev, struct rte_ml_model_params *params,\n+\t\t\tstruct cnxk_ml_model *model);\n \n #endif /* _MVTVM_ML_STUBS_H_ */\n",
    "prefixes": [
        "v7",
        "21/34"
    ]
}