get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 122824,
    "url": "https://patches.dpdk.org/api/patches/122824/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230201092310.23252-21-syalavarthi@marvell.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<20230201092310.23252-21-syalavarthi@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230201092310.23252-21-syalavarthi@marvell.com",
    "date": "2023-02-01T09:22:51",
    "name": "[v4,20/39] ml/cnxk: enable support to get model information",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d16316b06b56b4c709c7dc6e4acccd1b07677f74",
    "submitter": {
        "id": 2480,
        "url": "https://patches.dpdk.org/api/people/2480/?format=api",
        "name": "Srikanth Yalavarthi",
        "email": "syalavarthi@marvell.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20230201092310.23252-21-syalavarthi@marvell.com/mbox/",
    "series": [
        {
            "id": 26732,
            "url": "https://patches.dpdk.org/api/series/26732/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=26732",
            "date": "2023-02-01T09:22:31",
            "name": "Implementation of ML CNXK driver",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/26732/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/122824/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/122824/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 1690741B9D;\n\tWed,  1 Feb 2023 10:25:03 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E4FB842DCC;\n\tWed,  1 Feb 2023 10:23:35 +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 B379842D48\n for <dev@dpdk.org>; Wed,  1 Feb 2023 10:23:22 +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 3116LRXu024189 for <dev@dpdk.org>; Wed, 1 Feb 2023 01:23:21 -0800",
            "from dc5-exch01.marvell.com ([199.233.59.181])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3nfjr8rgv5-4\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Wed, 01 Feb 2023 01:23:21 -0800",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42;\n Wed, 1 Feb 2023 01:23:20 -0800",
            "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.42 via Frontend\n Transport; Wed, 1 Feb 2023 01:23:20 -0800",
            "from ml-host-33.caveonetworks.com (unknown [10.110.143.233])\n by maili.marvell.com (Postfix) with ESMTP id 268C95B6922;\n Wed,  1 Feb 2023 01:23:19 -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=6PjhkLuP8CvczEjlMG9M9Ndjl0pelzF953KSxVCkxeg=;\n b=T6cNT2/WZoXksHV0FP3x2+WBIcPZsL5+OtDGVF2vUZCYDviX0U1DBY7zJ7yXw/4viYd3\n QOmTTMwB3UVZavAkzLme8yRi1fndZ8Uf8SFbPJijrHmup9Q1JyfNph0fCmOs5eWHY96p\n xSNe5rQzBbKOPfuRTToJCUqVWKjq9XFan0V/+KuCFqj+empNFZeZ2VN+0LRIvF+sCBqx\n QOUc6IdaaCpwwJAM+xrqWNhFyJuuOyZxvhSeHd+A3WStZ1qMwE5uCuCbNR2GtKLubBt1\n N/OipXuCmwSBPpjbMQOFyoinH4x4JakNoZKG9ElrNqu8bgwvnzdHhVf2PvVVEnon0Ify Qg==",
        "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 v4 20/39] ml/cnxk: enable support to get model information",
        "Date": "Wed, 1 Feb 2023 01:22:51 -0800",
        "Message-ID": "<20230201092310.23252-21-syalavarthi@marvell.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20230201092310.23252-1-syalavarthi@marvell.com>",
        "References": "<20221208200220.20267-1-syalavarthi@marvell.com>\n <20230201092310.23252-1-syalavarthi@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "hkwANmlGGV-phgHO-6helvI2LHoLtDJc",
        "X-Proofpoint-ORIG-GUID": "hkwANmlGGV-phgHO-6helvI2LHoLtDJc",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1\n definitions=2023-02-01_03,2023-01-31_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 30911b7ffe..295b6f0a01 100644\n--- a/drivers/ml/cnxk/cn10k_ml_model.c\n+++ b/drivers/ml/cnxk/cn10k_ml_model.c\n@@ -356,3 +356,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 003f5aba36..dca282a498 100644\n--- a/drivers/ml/cnxk/cn10k_ml_model.h\n+++ b/drivers/ml/cnxk/cn10k_ml_model.h\n@@ -422,6 +422,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@@ -438,5 +446,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 295b7794ec..0d6030d36a 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": [
        "v4",
        "20/39"
    ]
}