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 EFF21A0032; Thu, 8 Dec 2022 20:35:43 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 061CE42D20; Thu, 8 Dec 2022 20:35:40 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 3BDCB4003F for ; Thu, 8 Dec 2022 20:35:38 +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 2B8J8KK7001363; Thu, 8 Dec 2022 11:35:37 -0800 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=1y3WPsisNh4t07H03WKBH2dZlrXQVhGoWJ6xFz51WU4=; b=aLkPxIUmrDlsxGgE82+bTXEzHgcOAhsgHm9j4yOSez3oXjEk0tEVK919z75rI3zaRA36 5JhihEwZJDiaz6/PE2ztqEwOi30TyMM9zevl50WP07MOFd2SnnklFKm7iNbLU/VPyYQe Z53PYaFFyG0LYXSu1gBmrwZxqzqwsOX2W9oC2ddaJ49GzHkwIxOXQflXuf3ah1LxCuFP 17MH6TUqjsr1wu6ytxF8cInaezIkOUioi6CWWICyrWZRgO7DglwhgUvd3bmyW3VvOPKN TbxkCllQFZOi6PPoVjE9X75TNkz8g6cdfcadRB+X3o1Z6iAnrREiJAJzI6x6vZRCSJXJ AQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3mb22svkjj-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 08 Dec 2022 11:35:37 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 8 Dec 2022 11:35:35 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 8 Dec 2022 11:35:35 -0800 Received: from ml-host-33.caveonetworks.com (unknown [10.110.143.233]) by maili.marvell.com (Postfix) with ESMTP id 30C553F7066; Thu, 8 Dec 2022 11:35:35 -0800 (PST) From: Srikanth Yalavarthi To: Thomas Monjalon , Srikanth Yalavarthi CC: , , , Subject: [PATCH v1 1/4] common/ml: add initial files for ML common code Date: Thu, 8 Dec 2022 11:35:29 -0800 Message-ID: <20221208193532.16718-2-syalavarthi@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221208193532.16718-1-syalavarthi@marvell.com> References: <20221208193532.16718-1-syalavarthi@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: 4jt1QvDG_IT20M5RHyn4EG0sjFSUXwf0 X-Proofpoint-GUID: 4jt1QvDG_IT20M5RHyn4EG0sjFSUXwf0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-08_11,2022-12-08_01,2022-06-22_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 Added initial files for common ML driver code. Implemented ML type to size conversion, type to string and format to string conversion utility functions. Signed-off-by: Srikanth Yalavarthi --- Depends-on: series-26046 ("app/mldev: implement test framework for mldev") MAINTAINERS | 8 +++ drivers/common/meson.build | 1 + drivers/common/ml/meson.build | 20 +++++++ drivers/common/ml/ml_utils.c | 110 ++++++++++++++++++++++++++++++++++ drivers/common/ml/ml_utils.h | 50 ++++++++++++++++ drivers/common/ml/version.map | 9 +++ 6 files changed, 198 insertions(+) create mode 100644 drivers/common/ml/meson.build create mode 100644 drivers/common/ml/ml_utils.c create mode 100644 drivers/common/ml/ml_utils.h create mode 100644 drivers/common/ml/version.map diff --git a/MAINTAINERS b/MAINTAINERS index 5fa276fafa..6412209bff 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1431,6 +1431,14 @@ F: drivers/raw/dpaa2_cmdif/ F: doc/guides/rawdevs/dpaa2_cmdif.rst +ML Device Drivers +------------------------ + +ML common code +M: Srikanth Yalavarthi +F: drivers/common/ml/ + + Packet processing ----------------- diff --git a/drivers/common/meson.build b/drivers/common/meson.build index b63d899d50..0878dde0a0 100644 --- a/drivers/common/meson.build +++ b/drivers/common/meson.build @@ -9,4 +9,5 @@ drivers = [ 'idpf', 'mvep', 'octeontx', + 'ml', ] diff --git a/drivers/common/ml/meson.build b/drivers/common/ml/meson.build new file mode 100644 index 0000000000..2749ab6c2e --- /dev/null +++ b/drivers/common/ml/meson.build @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2022 Marvell. + +if not is_linux or not dpdk_conf.get('RTE_ARCH_64') + build = false + reason = 'only supported on 64-bit Linux' + subdir_done() +endif + +headers = files( + 'ml_utils.h', +) + +sources = files( + 'ml_utils.c', +) + +deps += ['mldev'] + +pmd_supports_disable_iova_as_pa = true diff --git a/drivers/common/ml/ml_utils.c b/drivers/common/ml/ml_utils.c new file mode 100644 index 0000000000..45c1f76a54 --- /dev/null +++ b/drivers/common/ml/ml_utils.c @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 Marvell. + */ + +#include + +#include "ml_utils.h" + +int +ml_io_type_size_get(enum rte_ml_io_type type) +{ + switch (type) { + case RTE_ML_IO_TYPE_UNKNOWN: + return -EINVAL; + case RTE_ML_IO_TYPE_INT8: + return sizeof(int8_t); + case RTE_ML_IO_TYPE_UINT8: + return sizeof(uint8_t); + case RTE_ML_IO_TYPE_INT16: + return sizeof(int16_t); + case RTE_ML_IO_TYPE_UINT16: + return sizeof(uint16_t); + case RTE_ML_IO_TYPE_INT32: + return sizeof(int32_t); + case RTE_ML_IO_TYPE_UINT32: + return sizeof(uint32_t); + case RTE_ML_IO_TYPE_FP8: + return sizeof(uint8_t); + case RTE_ML_IO_TYPE_FP16: + return sizeof(uint8_t) * 2; + case RTE_ML_IO_TYPE_FP32: + return sizeof(uint8_t) * 4; + case RTE_ML_IO_TYPE_BFLOAT16: + return sizeof(uint8_t) * 2; + default: + return -EINVAL; + } +} + +void +ml_io_type_to_str(enum rte_ml_io_type type, char *str, int len) +{ + switch (type) { + case RTE_ML_IO_TYPE_UNKNOWN: + rte_strlcpy(str, "unknown", len); + break; + case RTE_ML_IO_TYPE_INT8: + rte_strlcpy(str, "int8", len); + break; + case RTE_ML_IO_TYPE_UINT8: + rte_strlcpy(str, "uint8", len); + break; + case RTE_ML_IO_TYPE_INT16: + rte_strlcpy(str, "int16", len); + break; + case RTE_ML_IO_TYPE_UINT16: + rte_strlcpy(str, "uint16", len); + break; + case RTE_ML_IO_TYPE_INT32: + rte_strlcpy(str, "int32", len); + break; + case RTE_ML_IO_TYPE_UINT32: + rte_strlcpy(str, "uint32", len); + break; + case RTE_ML_IO_TYPE_FP8: + rte_strlcpy(str, "float8", len); + break; + case RTE_ML_IO_TYPE_FP16: + rte_strlcpy(str, "float16", len); + break; + case RTE_ML_IO_TYPE_FP32: + rte_strlcpy(str, "float32", len); + break; + case RTE_ML_IO_TYPE_BFLOAT16: + rte_strlcpy(str, "bfloat16", len); + break; + default: + rte_strlcpy(str, "invalid", len); + } +} + +void +ml_io_format_to_str(enum rte_ml_io_format format, char *str, int len) +{ + switch (format) { + case RTE_ML_IO_FORMAT_NCHW: + rte_strlcpy(str, "NCHW", len); + break; + case RTE_ML_IO_FORMAT_NHWC: + rte_strlcpy(str, "NHWC", len); + break; + case RTE_ML_IO_FORMAT_CHWN: + rte_strlcpy(str, "CHWN", len); + break; + case RTE_ML_IO_FORMAT_3D: + rte_strlcpy(str, "3D", len); + break; + case RTE_ML_IO_FORMAT_2D: + rte_strlcpy(str, "Matrix", len); + break; + case RTE_ML_IO_FORMAT_1D: + rte_strlcpy(str, "Vector", len); + break; + case RTE_ML_IO_FORMAT_SCALAR: + rte_strlcpy(str, "Scalar", len); + break; + default: + rte_strlcpy(str, "invalid", len); + } +} diff --git a/drivers/common/ml/ml_utils.h b/drivers/common/ml/ml_utils.h new file mode 100644 index 0000000000..b6adb98e04 --- /dev/null +++ b/drivers/common/ml/ml_utils.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 Marvell. + */ + +#ifndef _ML_UTILS_H_ +#define _ML_UTILS_H_ + +#include +#include + +/** + * Get the size an ML IO type in bytes. + * + * @param[in] type + * Enumeration of ML IO data type. + * + * @return + * - > 0, Size of the data type in bytes. + * - < 0, Error code on failure. + */ +__rte_internal +int ml_io_type_size_get(enum rte_ml_io_type type); + +/** + * Get the name of an ML IO type. + * + * @param[in] type + * Enumeration of ML IO data type. + * @param[in] str + * Address of character array. + * @param[in] len + * Length of character array. + */ +__rte_internal +void ml_io_type_to_str(enum rte_ml_io_type type, char *str, int len); + +/** + * Get the name of an ML IO format. + * + * @param[in] type + * Enumeration of ML IO format. + * @param[in] str + * Address of character array. + * @param[in] len + * Length of character array. + */ +__rte_internal +void ml_io_format_to_str(enum rte_ml_io_format format, char *str, int len); + +#endif /*_ML_UTILS_H_ */ diff --git a/drivers/common/ml/version.map b/drivers/common/ml/version.map new file mode 100644 index 0000000000..7e33755f2f --- /dev/null +++ b/drivers/common/ml/version.map @@ -0,0 +1,9 @@ +INTERNAL { + global: + + ml_io_type_size_get; + ml_io_type_to_str; + ml_io_format_to_str; + + local: *; +}; -- 2.17.1