Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/122832/?format=api
https://patches.dpdk.org/api/patches/122832/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230201092310.23252-15-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-15-syalavarthi@marvell.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20230201092310.23252-15-syalavarthi@marvell.com", "date": "2023-02-01T09:22:45", "name": "[v4,14/39] ml/cnxk: add internal structures for tiles and OCM", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "e6937414029f3280e7708d2622c458c9d5272f9c", "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-15-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/122832/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/122832/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 31BB641B9D;\n\tWed, 1 Feb 2023 10:25:53 +0100 (CET)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id A445A42FC4;\n\tWed, 1 Feb 2023 10:23:45 +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 5FAD142D29\n for <dev@dpdk.org>; Wed, 1 Feb 2023 10:23:24 +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 3116LRY3024189 for <dev@dpdk.org>; Wed, 1 Feb 2023 01:23:23 -0800", "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3nfjr8rgv6-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:23 -0800", "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.42;\n Wed, 1 Feb 2023 01:23:19 -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:19 -0800", "from ml-host-33.caveonetworks.com (unknown [10.110.143.233])\n by maili.marvell.com (Postfix) with ESMTP id 448903F70E8;\n Wed, 1 Feb 2023 01:23:17 -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=WI+s8waNHLHZmrv/uq349SRNHONgcYg1LjVDzGrkK98=;\n b=J8xYPQja4x4dYfKzXRGVTvvaxFDk+o/vLIsc1+m0eHnc6WGZOT80BmnQJ8B0B4q1PsSS\n kfwXggZMAZ9UnIwVD2zOxIhW4sKR06aRN6n0A891X9DIUWiUqHpBTE/MMywSh90UmRTo\n OgOIr5CnmfigzX2aQQM9tFKaOVkMbNxHm17HcFIVXc2QAc4ELjzauwXqBDoixjlFAxRu\n Rf9cHDte1HzgG8MVZo01qsFk3+TIBopGhbdxdIi5kGZgV3fHebjQ1dnqxkIO+La1aoi/\n vJu9WfPhI0zxcgB2kiNJWuuzrgCDGyNKxqhFvo6FTisqeUb5fgAr7PoU0uw2rLrofFUX vA==", "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 14/39] ml/cnxk: add internal structures for tiles and OCM", "Date": "Wed, 1 Feb 2023 01:22:45 -0800", "Message-ID": "<20230201092310.23252-15-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": "7j0h5b2TIk2AlWmHVX57So4_VMcXooSX", "X-Proofpoint-ORIG-GUID": "7j0h5b2TIk2AlWmHVX57So4_VMcXooSX", "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 internal structures to handle tile and OCM information and\nOCM to model memory mapping. Initialize the fields to platform\nspecific defaults and compute the OCM / tile requirements for model.\n\nSigned-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>\n---\n drivers/ml/cnxk/cn10k_ml_dev.h | 5 ++\n drivers/ml/cnxk/cn10k_ml_model.c | 53 +++++++++++++++++++++\n drivers/ml/cnxk/cn10k_ml_model.h | 6 +++\n drivers/ml/cnxk/cn10k_ml_ocm.c | 5 ++\n drivers/ml/cnxk/cn10k_ml_ocm.h | 79 ++++++++++++++++++++++++++++++++\n drivers/ml/cnxk/cn10k_ml_ops.c | 29 ++++++++++++\n drivers/ml/cnxk/meson.build | 2 +\n 7 files changed, 179 insertions(+)\n create mode 100644 drivers/ml/cnxk/cn10k_ml_ocm.c\n create mode 100644 drivers/ml/cnxk/cn10k_ml_ocm.h", "diff": "diff --git a/drivers/ml/cnxk/cn10k_ml_dev.h b/drivers/ml/cnxk/cn10k_ml_dev.h\nindex 7cf6268115..02a4496c97 100644\n--- a/drivers/ml/cnxk/cn10k_ml_dev.h\n+++ b/drivers/ml/cnxk/cn10k_ml_dev.h\n@@ -7,6 +7,8 @@\n \n #include <roc_api.h>\n \n+#include \"cn10k_ml_ocm.h\"\n+\n /* Marvell OCTEON CN10K ML PMD device name */\n #define MLDEV_NAME_CN10K_PMD ml_cn10k\n \n@@ -215,6 +217,9 @@ struct cn10k_ml_dev {\n \t/* Firmware */\n \tstruct cn10k_ml_fw fw;\n \n+\t/* OCM info */\n+\tstruct cn10k_ml_ocm ocm;\n+\n \t/* Number of models loaded */\n \tuint16_t nb_models_loaded;\n };\ndiff --git a/drivers/ml/cnxk/cn10k_ml_model.c b/drivers/ml/cnxk/cn10k_ml_model.c\nindex dafcae106b..30911b7ffe 100644\n--- a/drivers/ml/cnxk/cn10k_ml_model.c\n+++ b/drivers/ml/cnxk/cn10k_ml_model.c\n@@ -8,6 +8,7 @@\n \n #include \"cn10k_ml_dev.h\"\n #include \"cn10k_ml_model.h\"\n+#include \"cn10k_ml_ocm.h\"\n \n static enum rte_ml_io_type\n cn10k_ml_io_type_map(uint8_t type)\n@@ -303,3 +304,55 @@ cn10k_ml_model_addr_update(struct cn10k_ml_model *model, uint8_t *buffer, uint8_\n \t\t\t addr->output[i].sz_d, addr->output[i].sz_q);\n \t}\n }\n+\n+int\n+cn10k_ml_model_ocm_pages_count(struct cn10k_ml_dev *mldev, int16_t model_id, uint8_t *buffer,\n+\t\t\t uint16_t *wb_pages, uint16_t *scratch_pages)\n+{\n+\tstruct cn10k_ml_model_metadata *metadata;\n+\tstruct cn10k_ml_ocm *ocm;\n+\tuint64_t scratch_size;\n+\tuint64_t wb_size;\n+\n+\tmetadata = (struct cn10k_ml_model_metadata *)buffer;\n+\tocm = &mldev->ocm;\n+\n+\t/* Assume wb_size is zero for non-relocatable models */\n+\tif (metadata->model.ocm_relocatable)\n+\t\twb_size = metadata->model.ocm_wb_range_end - metadata->model.ocm_wb_range_start + 1;\n+\telse\n+\t\twb_size = 0;\n+\n+\tif (wb_size % ocm->page_size)\n+\t\t*wb_pages = wb_size / ocm->page_size + 1;\n+\telse\n+\t\t*wb_pages = wb_size / ocm->page_size;\n+\tplt_ml_dbg(\"model_id = %d, wb_size = %\" PRIu64 \", wb_pages = %u\", model_id, wb_size,\n+\t\t *wb_pages);\n+\n+\tscratch_size = ocm->size_per_tile - metadata->model.ocm_tmp_range_floor;\n+\tif (metadata->model.ocm_tmp_range_floor % ocm->page_size)\n+\t\t*scratch_pages = scratch_size / ocm->page_size + 1;\n+\telse\n+\t\t*scratch_pages = scratch_size / ocm->page_size;\n+\tplt_ml_dbg(\"model_id = %d, scratch_size = %\" PRIu64 \", scratch_pages = %u\", model_id,\n+\t\t scratch_size, *scratch_pages);\n+\n+\t/* Check if the model can be loaded on OCM */\n+\tif ((*wb_pages + *scratch_pages) > ML_CN10K_OCM_NUMPAGES) {\n+\t\tplt_err(\"Cannot create the model, OCM relocatable = %u\",\n+\t\t\tmetadata->model.ocm_relocatable);\n+\t\tplt_err(\"wb_pages (%u) + scratch_pages (%u) > %u\", *wb_pages, *scratch_pages,\n+\t\t\tML_CN10K_OCM_NUMPAGES);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\t/* Update scratch_pages to block the full tile for OCM non-relocatable model. This would\n+\t * prevent the library from allocating the remaining space on the tile to other models.\n+\t */\n+\tif (!metadata->model.ocm_relocatable)\n+\t\t*scratch_pages =\n+\t\t\tPLT_MAX(PLT_U64_CAST(*scratch_pages), PLT_U64_CAST(ML_CN10K_OCM_NUMPAGES));\n+\n+\treturn 0;\n+}\ndiff --git a/drivers/ml/cnxk/cn10k_ml_model.h b/drivers/ml/cnxk/cn10k_ml_model.h\nindex 7e276c3b12..ebd296c609 100644\n--- a/drivers/ml/cnxk/cn10k_ml_model.h\n+++ b/drivers/ml/cnxk/cn10k_ml_model.h\n@@ -10,6 +10,7 @@\n #include <roc_api.h>\n \n #include \"cn10k_ml_dev.h\"\n+#include \"cn10k_ml_ocm.h\"\n \n /* Model state */\n enum cn10k_ml_model_state {\n@@ -417,6 +418,9 @@ struct cn10k_ml_model {\n \t/* Address structure */\n \tstruct cn10k_ml_model_addr addr;\n \n+\t/* Tile and memory information object */\n+\tstruct cn10k_ml_ocm_model_map model_mem_map;\n+\n \t/* Spinlock, used to update model state */\n \tplt_spinlock_t lock;\n \n@@ -428,5 +432,7 @@ int cn10k_ml_model_metadata_check(uint8_t *buffer, uint64_t size);\n void cn10k_ml_model_metadata_update(struct cn10k_ml_model_metadata *metadata);\n 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 \n #endif /* _CN10K_ML_MODEL_H_ */\ndiff --git a/drivers/ml/cnxk/cn10k_ml_ocm.c b/drivers/ml/cnxk/cn10k_ml_ocm.c\nnew file mode 100644\nindex 0000000000..b1c62f2963\n--- /dev/null\n+++ b/drivers/ml/cnxk/cn10k_ml_ocm.c\n@@ -0,0 +1,5 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2022 Marvell.\n+ */\n+\n+#include \"cn10k_ml_ocm.h\"\ndiff --git a/drivers/ml/cnxk/cn10k_ml_ocm.h b/drivers/ml/cnxk/cn10k_ml_ocm.h\nnew file mode 100644\nindex 0000000000..44390396f9\n--- /dev/null\n+++ b/drivers/ml/cnxk/cn10k_ml_ocm.h\n@@ -0,0 +1,79 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2022 Marvell.\n+ */\n+\n+#ifndef _CN10K_ML_OCM_H_\n+#define _CN10K_ML_OCM_H_\n+\n+#include <rte_mldev.h>\n+\n+/* Page size in bytes. */\n+#define ML_CN10K_OCM_PAGESIZE 0x4000\n+\n+/* Number of OCM tiles. */\n+#define ML_CN10K_OCM_NUMTILES 0x8\n+\n+/* OCM in bytes, per tile. */\n+#define ML_CN10K_OCM_TILESIZE 0x100000\n+\n+/* OCM pages, per tile. */\n+#define ML_CN10K_OCM_NUMPAGES (ML_CN10K_OCM_TILESIZE / ML_CN10K_OCM_PAGESIZE)\n+\n+/* Maximum OCM mask words, per tile, 8 bit words. */\n+#define ML_CN10K_OCM_MASKWORDS (ML_CN10K_OCM_NUMPAGES / 8)\n+\n+/* OCM and Tile information structure */\n+struct cn10k_ml_ocm_tile_info {\n+\t/* Mask of used / allotted pages on tile's OCM */\n+\tuint8_t ocm_mask[ML_CN10K_OCM_MASKWORDS];\n+\n+\t/* Last pages in the tile's OCM used for weights and bias, default = -1 */\n+\tint last_wb_page;\n+\n+\t/* Number pages used for scratch memory on the tile's OCM */\n+\tuint16_t scratch_pages;\n+};\n+\n+/* Model OCM map structure */\n+struct cn10k_ml_ocm_model_map {\n+\t/* Status of OCM reservation */\n+\tbool ocm_reserved;\n+\n+\t/* Mask of OCM tiles for the model */\n+\tuint64_t tilemask;\n+\n+\t/* Start page for the model load, default = -1 */\n+\tint wb_page_start;\n+\n+\t/* Number of pages required for weights and bias */\n+\tuint16_t wb_pages;\n+\n+\t/* Number of pages required for scratch memory */\n+\tuint16_t scratch_pages;\n+};\n+\n+/* OCM state structure */\n+struct cn10k_ml_ocm {\n+\t/* OCM spinlock, used to update OCM state */\n+\trte_spinlock_t lock;\n+\n+\t/* Number of OCM tiles */\n+\tuint8_t num_tiles;\n+\n+\t/* OCM size per each tile */\n+\tuint64_t size_per_tile;\n+\n+\t/* Size of OCM page */\n+\tuint64_t page_size;\n+\n+\t/* Number of OCM pages */\n+\tuint16_t num_pages;\n+\n+\t/* Words per OCM mask */\n+\tuint16_t mask_words;\n+\n+\t/* OCM memory info and status*/\n+\tstruct cn10k_ml_ocm_tile_info tile_ocm_info[ML_CN10K_OCM_NUMTILES];\n+};\n+\n+#endif /* _CN10K_ML_OCM_H_ */\ndiff --git a/drivers/ml/cnxk/cn10k_ml_ops.c b/drivers/ml/cnxk/cn10k_ml_ops.c\nindex 20f15ec35d..9ccf52332f 100644\n--- a/drivers/ml/cnxk/cn10k_ml_ops.c\n+++ b/drivers/ml/cnxk/cn10k_ml_ops.c\n@@ -126,8 +126,10 @@ cn10k_ml_dev_configure(struct rte_ml_dev *dev, const struct rte_ml_dev_config *c\n \tstruct rte_ml_dev_info dev_info;\n \tstruct cn10k_ml_model *model;\n \tstruct cn10k_ml_dev *mldev;\n+\tstruct cn10k_ml_ocm *ocm;\n \tstruct cn10k_ml_qp *qp;\n \tuint32_t mz_size;\n+\tuint16_t tile_id;\n \tint16_t model_id;\n \tuint16_t qp_id;\n \tint ret;\n@@ -250,6 +252,18 @@ cn10k_ml_dev_configure(struct rte_ml_dev *dev, const struct rte_ml_dev_config *c\n \t}\n \tdev->data->nb_models = conf->nb_models;\n \n+\tocm = &mldev->ocm;\n+\tocm->num_tiles = ML_CN10K_OCM_NUMTILES;\n+\tocm->size_per_tile = ML_CN10K_OCM_TILESIZE;\n+\tocm->page_size = ML_CN10K_OCM_PAGESIZE;\n+\tocm->num_pages = ocm->size_per_tile / ocm->page_size;\n+\tocm->mask_words = ocm->num_pages / (8 * sizeof(uint8_t));\n+\n+\tfor (tile_id = 0; tile_id < ocm->num_tiles; tile_id++)\n+\t\tocm->tile_ocm_info[tile_id].last_wb_page = -1;\n+\n+\trte_spinlock_init(&ocm->lock);\n+\n \tmldev->nb_models_loaded = 0;\n \tmldev->state = ML_CN10K_DEV_STATE_CONFIGURED;\n \n@@ -416,6 +430,8 @@ cn10k_ml_model_load(struct rte_ml_dev *dev, struct rte_ml_model_params *params,\n \tconst struct plt_memzone *mz;\n \tsize_t model_data_size;\n \tuint8_t *base_dma_addr;\n+\tuint16_t scratch_pages;\n+\tuint16_t wb_pages;\n \tuint64_t mz_size;\n \tuint16_t idx;\n \tbool found;\n@@ -441,6 +457,11 @@ cn10k_ml_model_load(struct rte_ml_dev *dev, struct rte_ml_model_params *params,\n \t\treturn -ENOMEM;\n \t}\n \n+\t/* Get WB and scratch pages, check if model can be loaded. */\n+\tret = cn10k_ml_model_ocm_pages_count(mldev, idx, params->addr, &wb_pages, &scratch_pages);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n \t/* Compute memzone size */\n \tmetadata = (struct cn10k_ml_model_metadata *)params->addr;\n \tmodel_data_size = metadata->init_model.file_size + metadata->main_model.file_size +\n@@ -478,6 +499,14 @@ cn10k_ml_model_load(struct rte_ml_dev *dev, struct rte_ml_model_params *params,\n \t/* Copy data from load to run. run address to be used by MLIP */\n \trte_memcpy(model->addr.base_dma_addr_run, model->addr.base_dma_addr_load, model_data_size);\n \n+\t/* Initialize model_mem_map */\n+\tmemset(&model->model_mem_map, 0, sizeof(struct cn10k_ml_ocm_model_map));\n+\tmodel->model_mem_map.ocm_reserved = false;\n+\tmodel->model_mem_map.tilemask = 0;\n+\tmodel->model_mem_map.wb_page_start = -1;\n+\tmodel->model_mem_map.wb_pages = wb_pages;\n+\tmodel->model_mem_map.scratch_pages = scratch_pages;\n+\n \tplt_spinlock_init(&model->lock);\n \tmodel->state = ML_CN10K_MODEL_STATE_LOADED;\n \tdev->data->models[idx] = model;\ndiff --git a/drivers/ml/cnxk/meson.build b/drivers/ml/cnxk/meson.build\nindex 799e8f2470..393bc629b0 100644\n--- a/drivers/ml/cnxk/meson.build\n+++ b/drivers/ml/cnxk/meson.build\n@@ -11,12 +11,14 @@ driver_sdk_headers = files(\n 'cn10k_ml_dev.h',\n 'cn10k_ml_ops.h',\n 'cn10k_ml_model.h',\n+ 'cn10k_ml_ocm.h',\n )\n \n sources = files(\n 'cn10k_ml_dev.c',\n 'cn10k_ml_ops.c',\n 'cn10k_ml_model.c',\n+ 'cn10k_ml_ocm.c',\n )\n \n deps += ['mldev', 'common_cnxk', 'kvargs', 'hash']\n", "prefixes": [ "v4", "14/39" ] }{ "id": 122832, "url": "