get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 131694,
    "url": "http://patchwork.dpdk.org/api/patches/131694/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230920072528.14185-22-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": "<20230920072528.14185-22-syalavarthi@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230920072528.14185-22-syalavarthi@marvell.com",
    "date": "2023-09-20T07:25:12",
    "name": "[v2,21/34] ml/cnxk: add support for identify model type",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "9fb1a10ee418399b45ed03c6fee48f47da85a828",
    "submitter": {
        "id": 2480,
        "url": "http://patchwork.dpdk.org/api/people/2480/?format=api",
        "name": "Srikanth Yalavarthi",
        "email": "syalavarthi@marvell.com"
    },
    "delegate": {
        "id": 310,
        "url": "http://patchwork.dpdk.org/api/users/310/?format=api",
        "username": "jerin",
        "first_name": "Jerin",
        "last_name": "Jacob",
        "email": "jerinj@marvell.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230920072528.14185-22-syalavarthi@marvell.com/mbox/",
    "series": [
        {
            "id": 29567,
            "url": "http://patchwork.dpdk.org/api/series/29567/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29567",
            "date": "2023-09-20T07:24:51",
            "name": "Implemenation of revised ml/cnxk driver",
            "version": 2,
            "mbox": "http://patchwork.dpdk.org/series/29567/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/131694/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/131694/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 D38BD425E4;\n\tWed, 20 Sep 2023 09:27:53 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 781E942D66;\n\tWed, 20 Sep 2023 09:26:00 +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 45F0C410D0\n for <dev@dpdk.org>; Wed, 20 Sep 2023 09:25: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 38K7JW10008355 for <dev@dpdk.org>; Wed, 20 Sep 2023 00:25:40 -0700",
            "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3t7htasykw-8\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Wed, 20 Sep 2023 00:25:40 -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, 20 Sep 2023 00:25:39 -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, 20 Sep 2023 00:25:39 -0700",
            "from ml-host-33.caveonetworks.com (unknown [10.110.143.233])\n by maili.marvell.com (Postfix) with ESMTP id F32065B6929;\n Wed, 20 Sep 2023 00:25:38 -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=9/rlZAMzUiCI5a7QVSICmhQEeMc0gQ5QZ11KaeYMI2U=;\n b=KRKX8119zmCELPmHQfwNYgo4m/kbc8EFDC6SYL3XFiso2n8EncVoR0b+fm0Z7q0m/V0i\n Bffq/or/LN2/H1a6WdjjzZslocPy3GXcZrZjAkn2RCAKNcX0ut3QzNebhXtTe7R63wil\n is8Rccdp7qu3Su66AAWd4Qem4Ox7fVXk/WumREVChSBFTv0eQfjggQI9muguvO9GGl84\n PCLYBTrL2wTM3S0u0qmFvve2W3fu2thavtY9neEK6qbSxX33v4Em/3c1DPESfo/nT+Xq\n UpL4P60thD13Dc6BEB2yIkaEVrpl4oZiUxeeDQg/Y4vn6MY+hHxZ/jAs9PgX8feai19H 7g==",
        "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 v2 21/34] ml/cnxk: add support for identify model type",
        "Date": "Wed, 20 Sep 2023 00:25:12 -0700",
        "Message-ID": "<20230920072528.14185-22-syalavarthi@marvell.com>",
        "X-Mailer": "git-send-email 2.41.0",
        "In-Reply-To": "<20230920072528.14185-1-syalavarthi@marvell.com>",
        "References": "<20230830155927.3566-1-syalavarthi@marvell.com>\n <20230920072528.14185-1-syalavarthi@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-ORIG-GUID": "D1fUyDUZ-AYRd2CW541UCTqmitPvjXA4",
        "X-Proofpoint-GUID": "D1fUyDUZ-AYRd2CW541UCTqmitPvjXA4",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26\n definitions=2023-09-20_02,2023-09-19_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": "Enable support to parse model buffer to identify the\nmodel type and model sub-type. Enabled basic checks\nfor Glow model type buffer.\n\nSigned-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>\nSigned-off-by: Anup Prabhu <aprabhu@marvell.com>\n---\n drivers/ml/cnxk/cnxk_ml_model.c  | 96 ++++++++++++++++++++++++++++++++\n drivers/ml/cnxk/cnxk_ml_model.h  |  1 +\n drivers/ml/cnxk/cnxk_ml_ops.c    |  9 +++\n drivers/ml/cnxk/meson.build      |  6 ++\n drivers/ml/cnxk/mvtvm_ml_model.c | 11 ++++\n 5 files changed, 123 insertions(+)\n create mode 100644 drivers/ml/cnxk/mvtvm_ml_model.c",
    "diff": "diff --git a/drivers/ml/cnxk/cnxk_ml_model.c b/drivers/ml/cnxk/cnxk_ml_model.c\nindex b069d4e3a5..746d3ca5a9 100644\n--- a/drivers/ml/cnxk/cnxk_ml_model.c\n+++ b/drivers/ml/cnxk/cnxk_ml_model.c\n@@ -2,11 +2,107 @@\n  * Copyright (c) 2023 Marvell.\n  */\n \n+#ifdef RTE_MLDEV_CNXK_ENABLE_MVTVM\n+#include <archive.h>\n+#include <archive_entry.h>\n+#endif\n+\n+#include <rte_hash_crc.h>\n #include <rte_mldev.h>\n \n+#include \"cn10k_ml_model.h\"\n+\n+#ifdef RTE_MLDEV_CNXK_ENABLE_MVTVM\n+#include \"mvtvm_ml_model.h\"\n+#endif\n+\n #include \"cnxk_ml_model.h\"\n #include \"cnxk_ml_utils.h\"\n \n+enum cnxk_ml_model_type\n+cnxk_ml_model_get_type(struct rte_ml_model_params *params)\n+{\n+\tstruct cn10k_ml_model_metadata_header *metadata_header;\n+\tuint32_t payload_crc32c;\n+\tuint32_t header_crc32c;\n+\n+#ifdef RTE_MLDEV_CNXK_ENABLE_MVTVM\n+\tstruct archive_entry *entry;\n+\tstruct archive *a;\n+\tuint8_t i;\n+\tint ret;\n+\n+\t/* Assume as archive and check for read status */\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\tgoto check_tvm;\n+\telse\n+\t\tgoto check_glow;\n+\n+check_tvm:\n+\tbool object_found[ML_MVTVM_MODEL_OBJECT_MAX] = {false, false, false};\n+\n+\t/* Parse buffer for available objects */\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\tobject_found[i] = true;\n+\t\t}\n+\t\tarchive_read_data_skip(a);\n+\t}\n+\n+\t/* Check if all objects are available */\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\treturn ML_CNXK_MODEL_TYPE_INVALID;\n+\t\t}\n+\t}\n+\n+\treturn ML_CNXK_MODEL_TYPE_TVM;\n+\n+check_glow:\n+#endif\n+\n+\t/* Check model magic string */\n+\tmetadata_header = (struct cn10k_ml_model_metadata_header *)params->addr;\n+\tif (strncmp((char *)metadata_header->magic, MRVL_ML_MODEL_MAGIC_STRING, 4) != 0) {\n+\t\tplt_err(\"Invalid Glow model, magic = %s\", metadata_header->magic);\n+\t\treturn ML_CNXK_MODEL_TYPE_INVALID;\n+\t}\n+\n+\t/* Header CRC check */\n+\tif (metadata_header->header_crc32c != 0) {\n+\t\theader_crc32c = rte_hash_crc(\n+\t\t\tparams->addr,\n+\t\t\tsizeof(struct cn10k_ml_model_metadata_header) - sizeof(uint32_t), 0);\n+\n+\t\tif (header_crc32c != metadata_header->header_crc32c) {\n+\t\t\tplt_err(\"Invalid Glow model, Header CRC mismatch\");\n+\t\t\treturn ML_CNXK_MODEL_TYPE_INVALID;\n+\t\t}\n+\t}\n+\n+\t/* Payload CRC check */\n+\tif (metadata_header->payload_crc32c != 0) {\n+\t\tpayload_crc32c = rte_hash_crc(\n+\t\t\tPLT_PTR_ADD(params->addr, sizeof(struct cn10k_ml_model_metadata_header)),\n+\t\t\tparams->size - sizeof(struct cn10k_ml_model_metadata_header), 0);\n+\n+\t\tif (payload_crc32c != metadata_header->payload_crc32c) {\n+\t\t\tplt_err(\"Invalid Glow model, Payload CRC mismatch\");\n+\t\t\treturn ML_CNXK_MODEL_TYPE_INVALID;\n+\t\t}\n+\t}\n+\n+\treturn ML_CNXK_MODEL_TYPE_GLOW;\n+}\n+\n void\n cnxk_ml_model_dump(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *model, FILE *fp)\n {\ndiff --git a/drivers/ml/cnxk/cnxk_ml_model.h b/drivers/ml/cnxk/cnxk_ml_model.h\nindex b5d6ab2b1e..577a96dc26 100644\n--- a/drivers/ml/cnxk/cnxk_ml_model.h\n+++ b/drivers/ml/cnxk/cnxk_ml_model.h\n@@ -181,6 +181,7 @@ struct cnxk_ml_model {\n \tset_poll_addr_t set_poll_addr;\n };\n \n+enum cnxk_ml_model_type cnxk_ml_model_get_type(struct rte_ml_model_params *params);\n void cnxk_ml_model_dump(struct cnxk_ml_dev *cnxk_mldev, struct cnxk_ml_model *model, FILE *fp);\n \n #endif /* _CNXK_ML_MODEL_H_ */\ndiff --git a/drivers/ml/cnxk/cnxk_ml_ops.c b/drivers/ml/cnxk/cnxk_ml_ops.c\nindex a20937ea11..052c69e510 100644\n--- a/drivers/ml/cnxk/cnxk_ml_ops.c\n+++ b/drivers/ml/cnxk/cnxk_ml_ops.c\n@@ -10,6 +10,7 @@\n #include \"cn10k_ml_ops.h\"\n \n #ifdef RTE_MLDEV_CNXK_ENABLE_MVTVM\n+#include \"mvtvm_ml_model.h\"\n #include \"mvtvm_ml_ops.h\"\n #endif\n \n@@ -1087,6 +1088,7 @@ cnxk_ml_model_load(struct rte_ml_dev *dev, struct rte_ml_model_params *params, u\n {\n \tstruct rte_ml_dev_info dev_info;\n \tstruct cnxk_ml_dev *cnxk_mldev;\n+\tenum cnxk_ml_model_type type;\n \tstruct cnxk_ml_model *model;\n \n \tchar str[RTE_MEMZONE_NAMESIZE];\n@@ -1102,6 +1104,12 @@ cnxk_ml_model_load(struct rte_ml_dev *dev, struct rte_ml_model_params *params, u\n \n \tcnxk_mldev = dev->data->dev_private;\n \n+\ttype = cnxk_ml_model_get_type(params);\n+\tif (type == ML_CNXK_MODEL_TYPE_INVALID) {\n+\t\tplt_err(\"Invalid / unsupported model type\");\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/* Find model ID */\n \tfound = false;\n \tfor (lcl_model_id = 0; lcl_model_id < dev->data->nb_models; lcl_model_id++) {\n@@ -1135,6 +1143,7 @@ cnxk_ml_model_load(struct rte_ml_dev *dev, struct rte_ml_model_params *params, u\n \n \tmodel = mz->addr;\n \tmodel->cnxk_mldev = cnxk_mldev;\n+\tmodel->type = type;\n \tmodel->model_id = lcl_model_id;\n \tmodel->info = PLT_PTR_ADD(\n \t\tmodel, PLT_ALIGN_CEIL(sizeof(struct cnxk_ml_model), dev_info.align_size));\ndiff --git a/drivers/ml/cnxk/meson.build b/drivers/ml/cnxk/meson.build\nindex 25b72cc8aa..09a62b5c55 100644\n--- a/drivers/ml/cnxk/meson.build\n+++ b/drivers/ml/cnxk/meson.build\n@@ -9,6 +9,11 @@ endif\n \n enable_mvtvm = true\n \n+if not libarchive.found()\n+        message('drivers/ml/cnxk: libarchive not found')\n+        enable_mvtvm = false\n+endif\n+\n if not jansson_dep.found()\n         message('drivers/ml/cnxk: jansson not found')\n         enable_mvtvm = false\n@@ -71,6 +76,7 @@ driver_sdk_headers += files(\n \n sources += files(\n         'mvtvm_ml_ops.c',\n+        'mvtvm_ml_model.c',\n )\n \n ext_deps += tvmrt_dep\ndiff --git a/drivers/ml/cnxk/mvtvm_ml_model.c b/drivers/ml/cnxk/mvtvm_ml_model.c\nnew file mode 100644\nindex 0000000000..6462267534\n--- /dev/null\n+++ b/drivers/ml/cnxk/mvtvm_ml_model.c\n@@ -0,0 +1,11 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2023 Marvell.\n+ */\n+\n+#include <rte_mldev.h>\n+\n+#include \"mvtvm_ml_model.h\"\n+\n+/* Objects list */\n+char mvtvm_object_list[ML_MVTVM_MODEL_OBJECT_MAX][RTE_ML_STR_MAX] = {\"mod.so\", \"mod.json\",\n+\t\t\t\t\t\t\t\t     \"mod.params\"};\n",
    "prefixes": [
        "v2",
        "21/34"
    ]
}