From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 19E00A0561; Sun, 19 Apr 2020 12:07:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 65B221D606; Sun, 19 Apr 2020 12:03:01 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id EE4FF1D43F for ; Sun, 19 Apr 2020 12:02:52 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03JA1FA5020166; Sun, 19 Apr 2020 03:02:32 -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-transfer-encoding : content-type; s=pfpt0818; bh=0E2opw5xlbtGrsMpD6xcobkch6id3JW8yx/yX6vj51Q=; b=cHf4iQh36DsgqYQqncWQSpAN2W9LZeCngl7gdRhdamBZPbO1XH08gG14aBocq8dhWDj5 v0fOuPjDm7K4X9K3SKSR6PUe98uu5ORsFoV24/KcYQvpo4cTRFQVAxfLxk46YK226+F1 O+7inrBnewLdDBCiZ8WVzHcXnL9tXmWJRfbf56/EPdhT03GGM/ujj4cjWPVijfgkpfZu 7SVQWjW9990pCeyPDIRDebuRH2K80an+n2cIrhu6Him0EstX4uE8i1dyrnSmUgD/Huwe BfWr1K1EdPrtb3w9HFy3x3LEOiVhCk2Ehww5iqA6VvqfrlgPAze4D3A1ZItB3BYEAyMC iw== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 30g12njxbp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 19 Apr 2020 03:02:32 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 19 Apr 2020 03:02:30 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 19 Apr 2020 03:02:29 -0700 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.2 via Frontend Transport; Sun, 19 Apr 2020 03:02:29 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 6E6B73F703F; Sun, 19 Apr 2020 03:02:27 -0700 (PDT) From: To: Jerin Jacob , Sunil Kumar Kori CC: , , , , Date: Sun, 19 Apr 2020 15:31:14 +0530 Message-ID: <20200419100133.3232316-15-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200419100133.3232316-1-jerinj@marvell.com> References: <20200413150116.734047-1-jerinj@marvell.com> <20200419100133.3232316-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-19_02:2020-04-17, 2020-04-19 signatures=0 Subject: [dpdk-dev] [PATCH v6 14/33] eal/trace: implement provider payload X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jerin Jacob The trace function payloads such as rte_trace_point_emit_* have dual functions. The first to emit the payload for the registration function and the second one to act as trace mem emitters a.k.a provider payload. When it used as provider payload, those function copy the trace field to trace memory based on the tracing mode. Added payload definitions under ALLOW_EXPERIMENTAL define to allow the out_of_tree application to compile with out ALLOW_EXPERIMENTAL flag. Signed-off-by: Jerin Jacob Signed-off-by: Sunil Kumar Kori --- lib/librte_eal/include/rte_trace_point.h | 18 ++++ .../include/rte_trace_point_provider.h | 90 +++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/lib/librte_eal/include/rte_trace_point.h b/lib/librte_eal/include/rte_trace_point.h index f4e6d7e42..eca48db72 100644 --- a/lib/librte_eal/include/rte_trace_point.h +++ b/lib/librte_eal/include/rte_trace_point.h @@ -281,6 +281,24 @@ int __rte_trace_point_register(rte_trace_point_t *trace, const char *name, #include #endif +#ifndef __DOXYGEN__ + +#define rte_trace_point_emit_u64(in) __rte_trace_point_emit(in, uint64_t) +#define rte_trace_point_emit_i64(in) __rte_trace_point_emit(in, int64_t) +#define rte_trace_point_emit_u32(in) __rte_trace_point_emit(in, uint32_t) +#define rte_trace_point_emit_i32(in) __rte_trace_point_emit(in, int32_t) +#define rte_trace_point_emit_u16(in) __rte_trace_point_emit(in, uint16_t) +#define rte_trace_point_emit_i16(in) __rte_trace_point_emit(in, int16_t) +#define rte_trace_point_emit_u8(in) __rte_trace_point_emit(in, uint8_t) +#define rte_trace_point_emit_i8(in) __rte_trace_point_emit(in, int8_t) +#define rte_trace_point_emit_int(in) __rte_trace_point_emit(in, int32_t) +#define rte_trace_point_emit_long(in) __rte_trace_point_emit(in, long) +#define rte_trace_point_emit_float(in) __rte_trace_point_emit(in, float) +#define rte_trace_point_emit_double(in) __rte_trace_point_emit(in, double) +#define rte_trace_point_emit_ptr(in) __rte_trace_point_emit(in, uintptr_t) + +#endif + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/include/rte_trace_point_provider.h b/lib/librte_eal/include/rte_trace_point_provider.h index b8d727387..9fbfed757 100644 --- a/lib/librte_eal/include/rte_trace_point_provider.h +++ b/lib/librte_eal/include/rte_trace_point_provider.h @@ -9,6 +9,10 @@ #ifndef _RTE_TRACE_POINT_PROVIDER_H_ #define _RTE_TRACE_POINT_PROVIDER_H_ +#ifdef ALLOW_EXPERIMENTAL_API + +#include +#include #include #include #include @@ -38,4 +42,90 @@ struct __rte_trace_header { RTE_DECLARE_PER_LCORE(void *, trace_mem); +static __rte_always_inline void* +__rte_trace_mem_get(uint64_t in) +{ + struct __rte_trace_header *trace = RTE_PER_LCORE(trace_mem); + const uint16_t sz = in & __RTE_TRACE_FIELD_SIZE_MASK; + + /* Trace memory is not initialized for this thread */ + if (unlikely(trace == NULL)) { + __rte_trace_mem_per_thread_alloc(); + trace = RTE_PER_LCORE(trace_mem); + if (unlikely(trace == NULL)) + return NULL; + } + /* Check the wrap around case */ + uint32_t offset = trace->offset; + if (unlikely((offset + sz) >= trace->len)) { + /* Disable the trace event if it in DISCARD mode */ + if (unlikely(in & __RTE_TRACE_FIELD_ENABLE_DISCARD)) + return NULL; + + offset = 0; + } + /* Align to event header size */ + offset = RTE_ALIGN_CEIL(offset, __RTE_TRACE_EVENT_HEADER_SZ); + void *mem = RTE_PTR_ADD(&trace->mem[0], offset); + offset += sz; + trace->offset = offset; + + return mem; +} + +static __rte_always_inline void* +__rte_trace_point_emit_ev_header(void *mem, uint64_t in) +{ + uint64_t val; + + /* Event header [63:0] = id [63:48] | timestamp [47:0] */ + val = rte_get_tsc_cycles() & + ~(0xffffULL << __RTE_TRACE_EVENT_HEADER_ID_SHIFT); + val |= ((in & __RTE_TRACE_FIELD_ID_MASK) << + (__RTE_TRACE_EVENT_HEADER_ID_SHIFT - __RTE_TRACE_FIELD_ID_SHIFT)); + + *(uint64_t *)mem = val; + return RTE_PTR_ADD(mem, __RTE_TRACE_EVENT_HEADER_SZ); +} + +#define __rte_trace_point_emit_header_generic(t)\ +void *mem;\ +do {\ + const uint64_t val = __atomic_load_n(t, __ATOMIC_ACQUIRE);\ + if (likely(!(val & __RTE_TRACE_FIELD_ENABLE_MASK)))\ + return;\ + mem = __rte_trace_mem_get(val);\ + if (unlikely(mem == NULL)) \ + return;\ + mem = __rte_trace_point_emit_ev_header(mem, val);\ +} while (0) + +#define __rte_trace_point_emit_header_fp(t)\ + if (__rte_trace_point_fp_is_enabled() == false)\ + return;\ + __rte_trace_point_emit_header_generic(t) + +#define __rte_trace_point_emit(in, type)\ +do {\ + memcpy(mem, &(in), sizeof(in));\ + mem = RTE_PTR_ADD(mem, sizeof(in));\ +} while (0) + +#define rte_trace_point_emit_string(in)\ +do {\ + if (unlikely(in == NULL))\ + return;\ + rte_strscpy(mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX);\ + mem = RTE_PTR_ADD(mem, __RTE_TRACE_EMIT_STRING_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) + +#endif + #endif /* _RTE_TRACE_POINT_PROVIDER_H_ */ -- 2.25.1