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 2967E4614E; Thu, 30 Jan 2025 15:59:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 03EC2406BB; Thu, 30 Jan 2025 15:59:09 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 66A804067C for ; Thu, 30 Jan 2025 15:59:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738249146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4Lod1pqZ8ih1V9lRcZ4P8AVjKvpe5807ErLNVnHkklo=; b=WbaLI7Lk+ItrZQMuBQawF7bYHjSmX3xU7eEBYPZukGSV7Ps3LhnklW/5so82PS3b9+/Sk6 QcTIA4lBQK0OndcsydGx/ACC6z15Ic6ohwuKg7ImItjEy3pvwtPU0Od9TmI5er9TfbLB0O KKq6ZB/yv1OGdzuSIvKHnR0MaG6PCmA= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-459-F26W2lv5O3GZMzkZfGwHjA-1; Thu, 30 Jan 2025 09:59:02 -0500 X-MC-Unique: F26W2lv5O3GZMzkZfGwHjA-1 X-Mimecast-MFC-AGG-ID: F26W2lv5O3GZMzkZfGwHjA Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6BBF919560AF; Thu, 30 Jan 2025 14:58:59 +0000 (UTC) Received: from dmarchan.com (unknown [10.45.225.14]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6A6E019560A7; Thu, 30 Jan 2025 14:58:56 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Jerin Jacob , Sunil Kumar Kori , Tyler Retzlaff , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Subject: [PATCH v2 1/3] trace: support expression for blob length Date: Thu, 30 Jan 2025 15:58:47 +0100 Message-ID: <20250130145849.82003-1-david.marchand@redhat.com> In-Reply-To: <20250124161408.310581-1-david.marchand@redhat.com> References: <20250124161408.310581-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HKk5-RaTWiZRymfBw9RGGojear1Ug5nKTzgco4FIf4k_1738249141 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 Support any expression as a blob length by using an intermediate variable in the trace point emitter itself. This also avoids any side effect on the passed variable. Signed-off-by: David Marchand --- Changes since v1: - removed code relying on arguments in "registering" rte_trace_point_emit_blob implementation (see patch 3), - moved build check in non registering __rte_trace_point_emit, --- lib/eal/include/rte_trace_point.h | 12 ++++++---- lib/eal/include/rte_trace_point_register.h | 2 +- lib/ethdev/ethdev_trace.h | 27 ++++++---------------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trace_point.h index b24db3b6da..a162502002 100644 --- a/lib/eal/include/rte_trace_point.h +++ b/lib/eal/include/rte_trace_point.h @@ -378,6 +378,7 @@ do { \ #define __rte_trace_point_emit(in, type) \ do { \ + RTE_BUILD_BUG_ON(sizeof(type) != sizeof(typeof(in))); \ memcpy(mem, &(in), sizeof(in)); \ mem = RTE_PTR_ADD(mem, sizeof(in)); \ } while (0) @@ -392,13 +393,14 @@ do { \ #define rte_trace_point_emit_blob(in, len) \ do { \ + uint8_t size = len; \ 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); \ + if (size > RTE_TRACE_BLOB_LEN_MAX) \ + size = RTE_TRACE_BLOB_LEN_MAX; \ + __rte_trace_point_emit(size, uint8_t); \ + memcpy(mem, in, size); \ + memset(RTE_PTR_ADD(mem, size), 0, RTE_TRACE_BLOB_LEN_MAX - size); \ mem = RTE_PTR_ADD(mem, RTE_TRACE_BLOB_LEN_MAX); \ } while (0) diff --git a/lib/eal/include/rte_trace_point_register.h b/lib/eal/include/rte_trace_point_register.h index 748c931830..1d6198b32f 100644 --- a/lib/eal/include/rte_trace_point_register.h +++ b/lib/eal/include/rte_trace_point_register.h @@ -37,7 +37,7 @@ RTE_INIT(trace##_init) \ #define __rte_trace_point_emit(in, type) \ do { \ - RTE_BUILD_BUG_ON(sizeof(type) != sizeof(typeof(in))); \ + RTE_SET_USED(in); \ __rte_trace_point_emit_field(sizeof(type), RTE_STR(in), \ RTE_STR(type)); \ } while (0) diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h index 5951ae2d99..c65b78590a 100644 --- a/lib/ethdev/ethdev_trace.h +++ b/lib/ethdev/ethdev_trace.h @@ -860,10 +860,8 @@ RTE_TRACE_POINT( rte_ethdev_trace_mac_addr_add, RTE_TRACE_POINT_ARGS(uint16_t port_id, const struct rte_ether_addr *addr, uint32_t pool, int ret), - uint8_t len = RTE_ETHER_ADDR_LEN; - rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_blob(addr->addr_bytes, len); + rte_trace_point_emit_blob(addr->addr_bytes, RTE_ETHER_ADDR_LEN); rte_trace_point_emit_u32(pool); rte_trace_point_emit_int(ret); ) @@ -872,20 +870,16 @@ RTE_TRACE_POINT( rte_ethdev_trace_mac_addr_remove, RTE_TRACE_POINT_ARGS(uint16_t port_id, const struct rte_ether_addr *addr), - uint8_t len = RTE_ETHER_ADDR_LEN; - rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_blob(addr->addr_bytes, len); + rte_trace_point_emit_blob(addr->addr_bytes, RTE_ETHER_ADDR_LEN); ) RTE_TRACE_POINT( rte_ethdev_trace_default_mac_addr_set, RTE_TRACE_POINT_ARGS(uint16_t port_id, const struct rte_ether_addr *addr), - uint8_t len = RTE_ETHER_ADDR_LEN; - rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_blob(addr->addr_bytes, len); + rte_trace_point_emit_blob(addr->addr_bytes, RTE_ETHER_ADDR_LEN); ) RTE_TRACE_POINT( @@ -1102,11 +1096,9 @@ RTE_TRACE_POINT( RTE_TRACE_POINT_ARGS(uint16_t port_id, const struct rte_ether_addr *mc_addr_set, uint32_t nb_mc_addr, int ret), - uint8_t len = nb_mc_addr * RTE_ETHER_ADDR_LEN; - rte_trace_point_emit_u16(port_id); rte_trace_point_emit_u32(nb_mc_addr); - rte_trace_point_emit_blob(mc_addr_set, len); + rte_trace_point_emit_blob(mc_addr_set, nb_mc_addr * RTE_ETHER_ADDR_LEN); rte_trace_point_emit_int(ret); ) @@ -1214,13 +1206,10 @@ RTE_TRACE_POINT( rte_ethdev_trace_get_dcb_info, RTE_TRACE_POINT_ARGS(uint16_t port_id, const struct rte_eth_dcb_info *dcb_info, int ret), - uint8_t num_user_priorities = RTE_ETH_DCB_NUM_USER_PRIORITIES; - uint8_t num_tcs = RTE_ETH_DCB_NUM_TCS; - rte_trace_point_emit_u16(port_id); rte_trace_point_emit_u8(dcb_info->nb_tcs); - rte_trace_point_emit_blob(dcb_info->prio_tc, num_user_priorities); - rte_trace_point_emit_blob(dcb_info->tc_bws, num_tcs); + rte_trace_point_emit_blob(dcb_info->prio_tc, RTE_ETH_DCB_NUM_USER_PRIORITIES); + rte_trace_point_emit_blob(dcb_info->tc_bws, RTE_ETH_DCB_NUM_TCS); rte_trace_point_emit_int(ret); ) @@ -2126,10 +2115,8 @@ RTE_TRACE_POINT_FP( rte_eth_trace_macaddr_get, RTE_TRACE_POINT_ARGS(uint16_t port_id, const struct rte_ether_addr *mac_addr), - uint8_t len = RTE_ETHER_ADDR_LEN; - rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_blob(mac_addr->addr_bytes, len); + rte_trace_point_emit_blob(mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN); ) /* Called in loop in examples/ip_pipeline */ -- 2.48.1