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 12EBA41C42; Wed, 8 Feb 2023 18:15:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EEA4F41153; Wed, 8 Feb 2023 18:15:28 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id E374C40E6E for ; Wed, 8 Feb 2023 18:15:27 +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 318GR5Cc006439; Wed, 8 Feb 2023 09:13:12 -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 : content-transfer-encoding; s=pfpt0220; bh=TtUTVH/j73XIdxbh9Bm+vo1I1d0fSzOuU4Sx2aVFQEA=; b=foGi3xhL7dH32H2MbzWTFtfteF6VWPBeRZ26qXU6jewzFI63I/wVDDI3O6/i6T1aT934 dUz2BLN8VaLyUB4Pm0iU6Xglom/ogy7JisLzw9M5ScEAgAyMQpcC6WzBDZrpKeaWGsvH oacwws0RklDP9CFruqI06lEJ/1UWOxYSM+RUaRFpGH4d6GfWEQbvurGPSx5mbP67+S2a w6LS0DeddxfZPOHgydTWxIF5w4D/NaSUYpAoqlr/W+KD4ohwr+Sgtw1NHqUOBsNVVTkt tdsAEG4CjfX2XNMuFtqlDxRQSeLSAWfs/SfK0YBfVzJLJrKfP8t4zpIk8fFjxubJD5Wq ug== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3nkdyrwxgf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 08 Feb 2023 09:13:12 -0800 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; Wed, 8 Feb 2023 09:13:10 -0800 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; Wed, 8 Feb 2023 09:13:10 -0800 Received: from localhost.localdomain (unknown [10.28.36.185]) by maili.marvell.com (Postfix) with ESMTP id AFE893F7075; Wed, 8 Feb 2023 09:12:48 -0800 (PST) From: Ankur Dwivedi To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Ankur Dwivedi Subject: [PATCH v11 1/6] eal: trace: add trace point emit for blob Date: Wed, 8 Feb 2023 22:42:10 +0530 Message-ID: <20230208171215.787063-2-adwivedi@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230208171215.787063-1-adwivedi@marvell.com> References: <20230208132824.775985-1-adwivedi@marvell.com> <20230208171215.787063-1-adwivedi@marvell.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Proofpoint-ORIG-GUID: 8xbTVx4vJHhk_paBqn_PalwZw9K-4OD2 X-Proofpoint-GUID: 8xbTVx4vJHhk_paBqn_PalwZw9K-4OD2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-08_08,2023-02-08_02,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 Adds a trace point emit function for capturing a blob. The blob captures the length passed by the application followed by the array. The maximum blob bytes which can be captured is bounded by RTE_TRACE_BLOB_LEN_MAX macro. The value for max blob length macro is 64 bytes. If the length is less than 64 the remaining trailing bytes are set to zero. This patch also adds test case for emit blob tracepoint function. Signed-off-by: Ankur Dwivedi Acked-by: Morten Brørup Acked-by: Sunil Kumar Kori Acked-by: Jerin Jacob Acked-by: Ferruh Yigit --- app/test/test_trace.c | 11 ++++++++ doc/guides/prog_guide/trace_lib.rst | 12 +++++++++ lib/eal/common/eal_common_trace_points.c | 2 ++ lib/eal/include/rte_eal_trace.h | 6 +++++ lib/eal/include/rte_trace_point.h | 31 ++++++++++++++++++++++ lib/eal/include/rte_trace_point_register.h | 9 +++++++ lib/eal/version.map | 1 + 7 files changed, 72 insertions(+) diff --git a/app/test/test_trace.c b/app/test/test_trace.c index 6bedf14024..ad4a394a29 100644 --- a/app/test/test_trace.c +++ b/app/test/test_trace.c @@ -4,6 +4,7 @@ #include #include +#include #include #include "test.h" @@ -177,7 +178,12 @@ test_fp_trace_points(void) static int test_generic_trace_points(void) { + uint8_t arr[RTE_TRACE_BLOB_LEN_MAX]; int tmp; + int i; + + for (i = 0; i < RTE_TRACE_BLOB_LEN_MAX; i++) + arr[i] = i; rte_eal_trace_generic_void(); rte_eal_trace_generic_u64(0x10000000000000); @@ -195,6 +201,11 @@ test_generic_trace_points(void) rte_eal_trace_generic_ptr(&tmp); rte_eal_trace_generic_str("my string"); rte_eal_trace_generic_size_t(sizeof(void *)); + rte_eal_trace_generic_blob(arr, 0); + rte_eal_trace_generic_blob(arr, 17); + rte_eal_trace_generic_blob(arr, RTE_TRACE_BLOB_LEN_MAX); + rte_eal_trace_generic_blob(arr, rte_rand() % + RTE_TRACE_BLOB_LEN_MAX); RTE_EAL_TRACE_GENERIC_FUNC; return TEST_SUCCESS; diff --git a/doc/guides/prog_guide/trace_lib.rst b/doc/guides/prog_guide/trace_lib.rst index 9a8f38073d..3e0ea5835c 100644 --- a/doc/guides/prog_guide/trace_lib.rst +++ b/doc/guides/prog_guide/trace_lib.rst @@ -352,3 +352,15 @@ event ID. The ``packet.header`` and ``packet.context`` will be written in the slow path at the time of trace memory creation. The ``trace.header`` and trace payload will be emitted when the tracepoint function is invoked. + +Limitations +----------- + +- The ``rte_trace_point_emit_blob()`` function can capture a maximum blob of + length ``RTE_TRACE_BLOB_LEN_MAX`` bytes. The application can call + ``rte_trace_point_emit_blob()`` multiple times with length less than or equal to + ``RTE_TRACE_BLOB_LEN_MAX``, if it needs to capture more than ``RTE_TRACE_BLOB_LEN_MAX`` + bytes. +- If the length passed to the ``rte_trace_point_emit_blob()`` is less than + ``RTE_TRACE_BLOB_LEN_MAX``, then the trailing ``(RTE_TRACE_BLOB_LEN_MAX - len)`` + bytes in the trace are set to zero. diff --git a/lib/eal/common/eal_common_trace_points.c b/lib/eal/common/eal_common_trace_points.c index 0b0b254615..051f89809c 100644 --- a/lib/eal/common/eal_common_trace_points.c +++ b/lib/eal/common/eal_common_trace_points.c @@ -40,6 +40,8 @@ RTE_TRACE_POINT_REGISTER(rte_eal_trace_generic_size_t, lib.eal.generic.size_t) RTE_TRACE_POINT_REGISTER(rte_eal_trace_generic_func, lib.eal.generic.func) +RTE_TRACE_POINT_REGISTER(rte_eal_trace_generic_blob, + lib.eal.generic.blob) RTE_TRACE_POINT_REGISTER(rte_eal_trace_alarm_set, lib.eal.alarm.set) diff --git a/lib/eal/include/rte_eal_trace.h b/lib/eal/include/rte_eal_trace.h index 5ef4398230..6f5c022558 100644 --- a/lib/eal/include/rte_eal_trace.h +++ b/lib/eal/include/rte_eal_trace.h @@ -143,6 +143,12 @@ RTE_TRACE_POINT( rte_trace_point_emit_string(func); ) +RTE_TRACE_POINT( + rte_eal_trace_generic_blob, + RTE_TRACE_POINT_ARGS(const void *in, uint8_t len), + rte_trace_point_emit_blob(in, len); +) + #define RTE_EAL_TRACE_GENERIC_FUNC rte_eal_trace_generic_func(__func__) /* Interrupt */ diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trace_point.h index 0f8700974f..4d6b5700dd 100644 --- a/lib/eal/include/rte_trace_point.h +++ b/lib/eal/include/rte_trace_point.h @@ -144,6 +144,16 @@ _tp _args \ #define rte_trace_point_emit_ptr(val) /** Tracepoint function payload for string datatype */ #define rte_trace_point_emit_string(val) +/** + * Tracepoint function to capture a blob. + * + * @param val + * Pointer to the array to be captured. + * @param len + * Length to be captured. The maximum supported length is + * RTE_TRACE_BLOB_LEN_MAX bytes. + */ +#define rte_trace_point_emit_blob(val, len) #endif /* __DOXYGEN__ */ @@ -152,6 +162,9 @@ _tp _args \ /** @internal Macro to define event header size. */ #define __RTE_TRACE_EVENT_HEADER_SZ sizeof(uint64_t) +/** Macro to define maximum emit length of blob. */ +#define RTE_TRACE_BLOB_LEN_MAX 64 + /** * Enable recording events of the given tracepoint in the trace buffer. * @@ -374,12 +387,30 @@ do { \ mem = RTE_PTR_ADD(mem, __RTE_TRACE_EMIT_STRING_LEN_MAX); \ } while (0) +#define rte_trace_point_emit_blob(in, len) \ +do { \ + if (unlikely(in == NULL)) \ + return; \ + if (len > RTE_TRACE_BLOB_LEN_MAX) \ + len = RTE_TRACE_BLOB_LEN_MAX; \ + __rte_trace_point_emit(len, uint8_t); \ + memcpy(mem, in, len); \ + memset(RTE_PTR_ADD(mem, len), 0, RTE_TRACE_BLOB_LEN_MAX - len); \ + mem = RTE_PTR_ADD(mem, RTE_TRACE_BLOB_LEN_MAX); \ +} while (0) + #else #define __rte_trace_point_emit_header_generic(t) RTE_SET_USED(t) #define __rte_trace_point_emit_header_fp(t) RTE_SET_USED(t) #define __rte_trace_point_emit(in, type) RTE_SET_USED(in) #define rte_trace_point_emit_string(in) RTE_SET_USED(in) +#define rte_trace_point_emit_blob(in, len) \ +do { \ + RTE_SET_USED(in); \ + RTE_SET_USED(len); \ +} while (0) + #endif /* ALLOW_EXPERIMENTAL_API */ #endif /* _RTE_TRACE_POINT_REGISTER_H_ */ diff --git a/lib/eal/include/rte_trace_point_register.h b/lib/eal/include/rte_trace_point_register.h index a32f4d731b..a9682d3f22 100644 --- a/lib/eal/include/rte_trace_point_register.h +++ b/lib/eal/include/rte_trace_point_register.h @@ -47,6 +47,15 @@ do { \ RTE_STR(in)"[32]", "string_bounded_t"); \ } while (0) +#define rte_trace_point_emit_blob(in, len) \ +do { \ + RTE_SET_USED(in); \ + __rte_trace_point_emit(len, uint8_t); \ + __rte_trace_point_emit_field(RTE_TRACE_BLOB_LEN_MAX, \ + RTE_STR(in)"[" RTE_STR(RTE_TRACE_BLOB_LEN_MAX)"]", \ + RTE_STR(uint8_t)); \ +} while (0) + #ifdef __cplusplus } #endif diff --git a/lib/eal/version.map b/lib/eal/version.map index 6523102157..21aa1b8ce3 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -442,6 +442,7 @@ EXPERIMENTAL { # added in 23.03 rte_thread_set_name; + __rte_eal_trace_generic_blob; }; INTERNAL { -- 2.25.1