From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 98F7F41EB5; Thu, 16 Mar 2023 22:30:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 03B6042FD4; Thu, 16 Mar 2023 22:29:49 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 566AB42DBC for ; Thu, 16 Mar 2023 22:29:40 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32GFtBbg005959 for ; Thu, 16 Mar 2023 14:29:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=syjhgnkTXXhzW/YcPL/Yxo0eWvQcnX2IYOZtf77/9CU=; b=Xp5Moz9kyLA5l1qriRWDBn+JeENbJSZmggDFe4M3uufjQT8+K39Z4CUl+rvfXCB+J1xL lkGhpW5SRQ9FdGKIYbGoDPHW0cK8rm2jk2Ul887u+uxitiUyx2WtA3Xs0+yy6aevP5RG v001VdD+JfMrUWbGyIFDBwxwzjc3wb19oNtUURm0HNdKb/en85vZOXtwGwZ9IqAbZ019 fNgP9jVLxK6OmbyFJ+20e8knUau/WNQwHS8lKuWmIhP8NDrb3yl1T7TWXB/KBeimhplo NdcSv+7L4cwWzqUce7ODW0o7hUxV/KxBpMNXLLMH37dQ6QK49XlfH9RHjYRgxCEuYB3u gQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3pbxq2ucrk-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 16 Mar 2023 14:29:39 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 14:29:36 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Thu, 16 Mar 2023 14:29:36 -0700 Received: from ml-host-33.caveonetworks.com (unknown [10.110.143.233]) by maili.marvell.com (Postfix) with ESMTP id 80CD53F707C; Thu, 16 Mar 2023 14:29:36 -0700 (PDT) From: Srikanth Yalavarthi To: Srikanth Yalavarthi , Prince Takkar CC: , , , Subject: [PATCH v3 8/8] ml/cnxk: reduce levels of nested variables access Date: Thu, 16 Mar 2023 14:29:04 -0700 Message-ID: <20230316212904.9318-9-syalavarthi@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230316212904.9318-1-syalavarthi@marvell.com> References: <20230315135427.11489-1-syalavarthi@marvell.com> <20230316212904.9318-1-syalavarthi@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: 7UcxoN9e9NaQ2jv9zkc0Od-WPQJHWopU X-Proofpoint-ORIG-GUID: 7UcxoN9e9NaQ2jv9zkc0Od-WPQJHWopU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-16_14,2023-03-16_02,2023-02-09_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Reduce the number of levels to access nested structure variables. Use available variables or add new local pointer variables for access to keep the code uniform. Fixes: 298b2af4267f ("ml/cnxk: add internal structures for derived info") Fixes: 0b9c0768ce2b ("ml/cnxk: support model query") Signed-off-by: Srikanth Yalavarthi --- drivers/ml/cnxk/cn10k_ml_model.c | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/ml/cnxk/cn10k_ml_model.c b/drivers/ml/cnxk/cn10k_ml_model.c index ceffde8459..2ded05c5dc 100644 --- a/drivers/ml/cnxk/cn10k_ml_model.c +++ b/drivers/ml/cnxk/cn10k_ml_model.c @@ -272,8 +272,8 @@ cn10k_ml_model_addr_update(struct cn10k_ml_model *model, uint8_t *buffer, uint8_ addr->total_input_sz_q = 0; for (i = 0; i < metadata->model.num_input; i++) { addr->input[i].nb_elements = - model->metadata.input[i].shape.w * model->metadata.input[i].shape.x * - model->metadata.input[i].shape.y * model->metadata.input[i].shape.z; + metadata->input[i].shape.w * metadata->input[i].shape.x * + metadata->input[i].shape.y * metadata->input[i].shape.z; addr->input[i].sz_d = addr->input[i].nb_elements * rte_ml_io_type_size_get(metadata->input[i].input_type); addr->input[i].sz_q = addr->input[i].nb_elements * @@ -360,52 +360,52 @@ cn10k_ml_model_ocm_pages_count(struct cn10k_ml_dev *mldev, uint16_t model_id, ui void cn10k_ml_model_info_set(struct rte_ml_dev *dev, struct cn10k_ml_model *model) { + struct cn10k_ml_model_metadata *metadata; struct rte_ml_model_info *info; struct rte_ml_io_info *output; struct rte_ml_io_info *input; uint8_t i; + metadata = &model->metadata; info = PLT_PTR_CAST(model->info); input = PLT_PTR_ADD(info, sizeof(struct rte_ml_model_info)); - output = - PLT_PTR_ADD(input, model->metadata.model.num_input * sizeof(struct rte_ml_io_info)); + output = PLT_PTR_ADD(input, metadata->model.num_input * sizeof(struct rte_ml_io_info)); /* Set model info */ memset(info, 0, sizeof(struct rte_ml_model_info)); - rte_memcpy(info->name, model->metadata.model.name, MRVL_ML_MODEL_NAME_LEN); - snprintf(info->version, RTE_ML_STR_MAX, "%u.%u.%u.%u", model->metadata.model.version[0], - model->metadata.model.version[1], model->metadata.model.version[2], - model->metadata.model.version[3]); + rte_memcpy(info->name, metadata->model.name, MRVL_ML_MODEL_NAME_LEN); + snprintf(info->version, RTE_ML_STR_MAX, "%u.%u.%u.%u", metadata->model.version[0], + metadata->model.version[1], metadata->model.version[2], + metadata->model.version[3]); info->model_id = model->model_id; info->device_id = dev->data->dev_id; info->batch_size = model->batch_size; - info->nb_inputs = model->metadata.model.num_input; + info->nb_inputs = metadata->model.num_input; info->input_info = input; - info->nb_outputs = model->metadata.model.num_output; + info->nb_outputs = metadata->model.num_output; info->output_info = output; - info->wb_size = model->metadata.weights_bias.file_size; + info->wb_size = metadata->weights_bias.file_size; /* Set input info */ for (i = 0; i < info->nb_inputs; i++) { - rte_memcpy(input[i].name, model->metadata.input[i].input_name, - MRVL_ML_INPUT_NAME_LEN); - input[i].dtype = model->metadata.input[i].input_type; - input[i].qtype = model->metadata.input[i].model_input_type; - input[i].shape.format = model->metadata.input[i].shape.format; - input[i].shape.w = model->metadata.input[i].shape.w; - input[i].shape.x = model->metadata.input[i].shape.x; - input[i].shape.y = model->metadata.input[i].shape.y; - input[i].shape.z = model->metadata.input[i].shape.z; + rte_memcpy(input[i].name, metadata->input[i].input_name, MRVL_ML_INPUT_NAME_LEN); + input[i].dtype = metadata->input[i].input_type; + input[i].qtype = metadata->input[i].model_input_type; + input[i].shape.format = metadata->input[i].shape.format; + input[i].shape.w = metadata->input[i].shape.w; + input[i].shape.x = metadata->input[i].shape.x; + input[i].shape.y = metadata->input[i].shape.y; + input[i].shape.z = metadata->input[i].shape.z; } /* Set output info */ for (i = 0; i < info->nb_outputs; i++) { - rte_memcpy(output[i].name, model->metadata.output[i].output_name, + rte_memcpy(output[i].name, metadata->output[i].output_name, MRVL_ML_OUTPUT_NAME_LEN); - output[i].dtype = model->metadata.output[i].output_type; - output[i].qtype = model->metadata.output[i].model_output_type; + output[i].dtype = metadata->output[i].output_type; + output[i].qtype = metadata->output[i].model_output_type; output[i].shape.format = RTE_ML_IO_FORMAT_1D; - output[i].shape.w = model->metadata.output[i].size; + output[i].shape.w = metadata->output[i].size; output[i].shape.x = 1; output[i].shape.y = 1; output[i].shape.z = 1; -- 2.17.1