get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 121120,
    "url": "http://patches.dpdk.org/api/patches/121120/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20221220192645.14042-21-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": "<20221220192645.14042-21-syalavarthi@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20221220192645.14042-21-syalavarthi@marvell.com",
    "date": "2022-12-20T19:26:27",
    "name": "[v3,20/38] ml/cnxk: enable support to get model information",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d16316b06b56b4c709c7dc6e4acccd1b07677f74",
    "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/20221220192645.14042-21-syalavarthi@marvell.com/mbox/",
    "series": [
        {
            "id": 26199,
            "url": "http://patches.dpdk.org/api/series/26199/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=26199",
            "date": "2022-12-20T19:26:07",
            "name": "Implementation of ML CNXK driver",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/26199/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/121120/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/121120/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 4AA3CA0545;\n\tTue, 20 Dec 2022 20:29:11 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E78B142D80;\n\tTue, 20 Dec 2022 20:27:15 +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 A380040684\n for <dev@dpdk.org>; Tue, 20 Dec 2022 20:26:59 +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 2BKD9Qsd004952 for <dev@dpdk.org>; Tue, 20 Dec 2022 11:26:58 -0800",
            "from dc5-exch01.marvell.com ([199.233.59.181])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3mkapj2tpx-3\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Tue, 20 Dec 2022 11:26:58 -0800",
            "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.42;\n Tue, 20 Dec 2022 11:26:56 -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.42 via Frontend\n Transport; Tue, 20 Dec 2022 11:26:56 -0800",
            "from ml-host-33.caveonetworks.com (unknown [10.110.143.233])\n by maili.marvell.com (Postfix) with ESMTP id B2D3A3F7070;\n Tue, 20 Dec 2022 11:26:56 -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=KGX6G/oB5JXG3BhWzEVcUCLRMec/120uZ/4gjpIbSw8=;\n b=J6sHYXNczYBpQQNBdCLApF6IYAyBpWDSYSICZylYgodCyy9LTooyttqfvnJZKVROF0fi\n nIDjpBh4XURTSSbY60BFPqwOEaJ23qU36ikG/32v5hGyThPjc2gTbzh/V3PWxgxdKQF9\n HsqQ5D51Y1ls2jqrARvn1lteQmstO1pi1EUsUEZCJNv+MX7bprDybzX4uR33QU5bS3S0\n 20+y9UO2sdeOVQhJHjZ/Q8g/ZXRc84kPX0IdDA5dvlsbhTplgu9KQ60VHPlTmcSgwItJ\n 2QfF0P8To63Qk5WXL18lJOVIDbFAKmde3pNyrr5BCic5MXDy51kaY+XdcBEsVQOUHP/j xw==",
        "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 20/38] ml/cnxk: enable support to get model information",
        "Date": "Tue, 20 Dec 2022 11:26:27 -0800",
        "Message-ID": "<20221220192645.14042-21-syalavarthi@marvell.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20221220192645.14042-1-syalavarthi@marvell.com>",
        "References": "<20221208201806.21893-1-syalavarthi@marvell.com>\n <20221220192645.14042-1-syalavarthi@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Proofpoint-ORIG-GUID": "7zx9dmNMyRUCdyKF78iXhvKwYyimmcog",
        "X-Proofpoint-GUID": "7zx9dmNMyRUCdyKF78iXhvKwYyimmcog",
        "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-20_06,2022-12-20_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 driver functions to get model information. Added\ninternal functions to set and get model info.\n\nSigned-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>\n---\n drivers/ml/cnxk/cn10k_ml_model.c | 55 ++++++++++++++++++++++++++++++++\n drivers/ml/cnxk/cn10k_ml_model.h |  9 ++++++\n drivers/ml/cnxk/cn10k_ml_ops.c   | 37 ++++++++++++++++++---\n 3 files changed, 97 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/drivers/ml/cnxk/cn10k_ml_model.c b/drivers/ml/cnxk/cn10k_ml_model.c\nindex 2281f59591..8a988162fc 100644\n--- a/drivers/ml/cnxk/cn10k_ml_model.c\n+++ b/drivers/ml/cnxk/cn10k_ml_model.c\n@@ -340,3 +340,58 @@ cn10k_ml_model_ocm_pages_count(struct cn10k_ml_dev *mldev, int16_t model_id, uin\n \n \treturn 0;\n }\n+\n+void\n+cn10k_ml_model_info_set(struct rte_ml_dev *dev, struct cn10k_ml_model *model)\n+{\n+\tstruct rte_ml_model_info *info;\n+\tstruct rte_ml_io_info *output;\n+\tstruct rte_ml_io_info *input;\n+\tuint8_t i;\n+\n+\tinfo = PLT_PTR_CAST(model->info);\n+\tinput = PLT_PTR_ADD(info, sizeof(struct rte_ml_model_info));\n+\toutput =\n+\t\tPLT_PTR_ADD(input, model->metadata.model.num_input * sizeof(struct rte_ml_io_info));\n+\n+\t/* Set model info */\n+\tmemset(info, 0, sizeof(struct rte_ml_model_info));\n+\trte_memcpy(info->name, model->metadata.model.name, MRVL_ML_MODEL_NAME_LEN);\n+\tsnprintf(info->version, RTE_ML_STR_MAX, \"%u.%u.%u.%u\", model->metadata.model.version[0],\n+\t\t model->metadata.model.version[1], model->metadata.model.version[2],\n+\t\t model->metadata.model.version[3]);\n+\tinfo->model_id = model->model_id;\n+\tinfo->device_id = dev->data->dev_id;\n+\tinfo->batch_size = model->batch_size;\n+\tinfo->nb_inputs = model->metadata.model.num_input;\n+\tinfo->input_info = input;\n+\tinfo->nb_outputs = model->metadata.model.num_output;\n+\tinfo->output_info = output;\n+\tinfo->wb_size = model->metadata.weights_bias.file_size;\n+\n+\t/* Set input info */\n+\tfor (i = 0; i < info->nb_inputs; i++) {\n+\t\trte_memcpy(input[i].name, model->metadata.input[i].input_name,\n+\t\t\t   MRVL_ML_INPUT_NAME_LEN);\n+\t\tinput[i].dtype = model->metadata.input[i].input_type;\n+\t\tinput[i].qtype = model->metadata.input[i].model_input_type;\n+\t\tinput[i].shape.format = model->metadata.input[i].shape.format;\n+\t\tinput[i].shape.w = model->metadata.input[i].shape.w;\n+\t\tinput[i].shape.x = model->metadata.input[i].shape.x;\n+\t\tinput[i].shape.y = model->metadata.input[i].shape.y;\n+\t\tinput[i].shape.z = model->metadata.input[i].shape.z;\n+\t}\n+\n+\t/* Set output info */\n+\tfor (i = 0; i < info->nb_outputs; i++) {\n+\t\trte_memcpy(output[i].name, model->metadata.output[i].output_name,\n+\t\t\t   MRVL_ML_OUTPUT_NAME_LEN);\n+\t\toutput[i].dtype = model->metadata.output[i].output_type;\n+\t\toutput[i].qtype = model->metadata.output[i].model_output_type;\n+\t\toutput[i].shape.format = RTE_ML_IO_FORMAT_1D;\n+\t\toutput[i].shape.w = model->metadata.output[i].size;\n+\t\toutput[i].shape.x = 1;\n+\t\toutput[i].shape.y = 1;\n+\t\toutput[i].shape.z = 1;\n+\t}\n+}\ndiff --git a/drivers/ml/cnxk/cn10k_ml_model.h b/drivers/ml/cnxk/cn10k_ml_model.h\nindex 4b5a804c8b..2fd12846d4 100644\n--- a/drivers/ml/cnxk/cn10k_ml_model.h\n+++ b/drivers/ml/cnxk/cn10k_ml_model.h\n@@ -425,6 +425,14 @@ struct cn10k_ml_model {\n \t/* Tile and memory information object */\n \tstruct cn10k_ml_ocm_model_map model_mem_map;\n \n+\t/* Internal model information structure\n+\t * Size of the buffer = sizeof(struct rte_ml_model_info)\n+\t *                    + num_inputs * sizeof(struct rte_ml_io_info)\n+\t *                    + num_outputs * sizeof(struct rte_ml_io_info).\n+\t * Structures would be arranged in the same order in the buffer.\n+\t */\n+\tuint8_t *info;\n+\n \t/* Spinlock, used to update model state */\n \tplt_spinlock_t lock;\n \n@@ -441,5 +449,6 @@ void cn10k_ml_model_addr_update(struct cn10k_ml_model *model, uint8_t *buffer,\n \t\t\t\tuint8_t *base_dma_addr);\n int cn10k_ml_model_ocm_pages_count(struct cn10k_ml_dev *mldev, int16_t model_id, uint8_t *buffer,\n \t\t\t\t   uint16_t *wb_pages, uint16_t *scratch_pages);\n+void cn10k_ml_model_info_set(struct rte_ml_dev *dev, struct cn10k_ml_model *model);\n \n #endif /* _CN10K_ML_MODEL_H_ */\ndiff --git a/drivers/ml/cnxk/cn10k_ml_ops.c b/drivers/ml/cnxk/cn10k_ml_ops.c\nindex e902ef6420..dd1c7ae385 100644\n--- a/drivers/ml/cnxk/cn10k_ml_ops.c\n+++ b/drivers/ml/cnxk/cn10k_ml_ops.c\n@@ -506,6 +506,7 @@ cn10k_ml_model_load(struct rte_ml_dev *dev, struct rte_ml_model_params *params,\n \tchar str[RTE_MEMZONE_NAMESIZE];\n \tconst struct plt_memzone *mz;\n \tsize_t model_data_size;\n+\tsize_t model_info_size;\n \tuint8_t *base_dma_addr;\n \tuint16_t scratch_pages;\n \tuint16_t wb_pages;\n@@ -544,8 +545,13 @@ cn10k_ml_model_load(struct rte_ml_dev *dev, struct rte_ml_model_params *params,\n \tmodel_data_size = metadata->init_model.file_size + metadata->main_model.file_size +\n \t\t\t  metadata->finish_model.file_size + metadata->weights_bias.file_size;\n \tmodel_data_size = PLT_ALIGN_CEIL(model_data_size, ML_CN10K_ALIGN_SIZE);\n+\tmodel_info_size = sizeof(struct rte_ml_model_info) +\n+\t\t\t  metadata->model.num_input * sizeof(struct rte_ml_io_info) +\n+\t\t\t  metadata->model.num_output * sizeof(struct rte_ml_io_info);\n+\tmodel_info_size = PLT_ALIGN_CEIL(model_info_size, ML_CN10K_ALIGN_SIZE);\n+\n \tmz_size = PLT_ALIGN_CEIL(sizeof(struct cn10k_ml_model), ML_CN10K_ALIGN_SIZE) +\n-\t\t  2 * model_data_size +\n+\t\t  2 * model_data_size + model_info_size +\n \t\t  PLT_ALIGN_CEIL(sizeof(struct cn10k_ml_req), ML_CN10K_ALIGN_SIZE);\n \n \t/* Allocate memzone for model object and model data */\n@@ -585,10 +591,12 @@ cn10k_ml_model_load(struct rte_ml_dev *dev, struct rte_ml_model_params *params,\n \tmodel->model_mem_map.wb_pages = wb_pages;\n \tmodel->model_mem_map.scratch_pages = scratch_pages;\n \n+\t/* Set model info */\n+\tmodel->info = PLT_PTR_ADD(base_dma_addr, 2 * model_data_size);\n+\tcn10k_ml_model_info_set(dev, model);\n+\n \t/* Set slow-path request address and state */\n-\tmodel->req = PLT_PTR_ADD(\n-\t\tmz->addr, PLT_ALIGN_CEIL(sizeof(struct cn10k_ml_model), ML_CN10K_ALIGN_SIZE) +\n-\t\t\t\t  2 * model_data_size);\n+\tmodel->req = PLT_PTR_ADD(model->info, model_info_size);\n \n \tplt_spinlock_init(&model->lock);\n \tmodel->state = ML_CN10K_MODEL_STATE_LOADED;\n@@ -877,6 +885,26 @@ cn10k_ml_model_stop(struct rte_ml_dev *dev, int16_t model_id)\n \treturn ret;\n }\n \n+static int\n+cn10k_ml_model_info_get(struct rte_ml_dev *dev, int16_t model_id,\n+\t\t\tstruct rte_ml_model_info *model_info)\n+{\n+\tstruct cn10k_ml_model *model;\n+\n+\tmodel = dev->data->models[model_id];\n+\n+\tif (model == NULL) {\n+\t\tplt_err(\"Invalid model_id = %d\", model_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trte_memcpy(model_info, model->info, sizeof(struct rte_ml_model_info));\n+\tmodel_info->input_info = ((struct rte_ml_model_info *)model->info)->input_info;\n+\tmodel_info->output_info = ((struct rte_ml_model_info *)model->info)->output_info;\n+\n+\treturn 0;\n+}\n+\n struct rte_ml_dev_ops cn10k_ml_ops = {\n \t/* Device control ops */\n \t.dev_info_get = cn10k_ml_dev_info_get,\n@@ -894,4 +922,5 @@ struct rte_ml_dev_ops cn10k_ml_ops = {\n \t.model_unload = cn10k_ml_model_unload,\n \t.model_start = cn10k_ml_model_start,\n \t.model_stop = cn10k_ml_model_stop,\n+\t.model_info_get = cn10k_ml_model_info_get,\n };\n",
    "prefixes": [
        "v3",
        "20/38"
    ]
}