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 E8F01A0524 for ; Fri, 5 Feb 2021 12:37:08 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DFC174067B; Fri, 5 Feb 2021 12:37:08 +0100 (CET) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mails.dpdk.org (Postfix) with ESMTP id 52B4A188949 for ; Fri, 5 Feb 2021 12:37:07 +0100 (CET) Received: by mail-wr1-f51.google.com with SMTP id g10so7356792wrx.1 for ; Fri, 05 Feb 2021 03:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=03cVy9KdLqsvt3pJnYt19iDXzWXI3AFOKm0QjkK9BTo=; b=iiSlN/M0EWP/Iww3LCEiWITASiWK2Ess6DE7v//t7zX/lLtJHXuwsyiczDvin5JAND H8j8Z9OT2t6HuNqyDoK83da0cbse4GKDptmTNOrFl2gPnhjyb3zqMup6E4vLYz4o3yWq BYY9Ux3Lltn/FYrJ+p4DOHOybiOM1sTAM8AYE0r7foe6fKg5wcymgjsHUbbF36Ry4qmj BTDhmnvkF0NnDa3X+dcNG3NTqBF3ZLlKgqg7P7eGVzpGof/F8M7VJsNVOgIneTeBuFsl GPol9jPdUHel9vFxrpG3/Gv8QD8zWqpf7YAJ68zSfIsR1FJjmK4kChLbT81r0Vj2E9Yy bj8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=03cVy9KdLqsvt3pJnYt19iDXzWXI3AFOKm0QjkK9BTo=; b=DAg6EM5rzo8e/6o/JuxQKxKNPlzudMxKsJ7lxCiDYbHNf/rflXSYyCWb25NgiQKfpL PFy3Hnz7szS/fQrXU5LulS/YM2+X9c3p3XQvhpBQ8fOeVQO2Hihfnytod1SgbFBstsRZ k3GOv/13BNlHHI9KjPAgGF/KzK/yswin0yRi/TSS6kc4qVMa0CxoQuME07DHobpGJq41 KurlrLcxXZrhoS9OK3hhVQbgVboZac5R4SOuokYPLIHtZui5qPQce6lsk6ODY3Simx06 GYMs03qfXUryrSXuDc1pf3qOjiwmuKhiPIA/YySow2bq5ItwJLOOudJuW4GSVih26p8Y C38g== X-Gm-Message-State: AOAM531d2sPej8nOuaJdAMutqC3+9GqNKPdeHKEyQbe+vFxUtR9ZF6DK ooLAlwZXC1kEXpDUeF4IYCk= X-Google-Smtp-Source: ABdhPJxFbGDPS6NXuQGwng8hpAbsyZcAEyIbbMPduTtvxTUiCJIy5HWSMvW/rONQho3NK/eD57PB0A== X-Received: by 2002:a5d:65ca:: with SMTP id e10mr4689601wrw.166.1612525027113; Fri, 05 Feb 2021 03:37:07 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id s23sm8438538wmc.35.2021.02.05.03.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 03:37:06 -0800 (PST) From: luca.boccassi@gmail.com To: Jiawei Wang Cc: Viacheslav Ovsiienko , Ferruh Yigit , dpdk stable Date: Fri, 5 Feb 2021 11:18:29 +0000 Message-Id: <20210205111920.1272063-223-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205111920.1272063-1-luca.boccassi@gmail.com> References: <20210205111920.1272063-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'app/testpmd: fix packets dump overlapping' has been queued to stable release 20.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/07/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/016bb40b6cf6211ea64bef22065b9454a95c681d Thanks. Luca Boccassi --- >From 016bb40b6cf6211ea64bef22065b9454a95c681d Mon Sep 17 00:00:00 2001 From: Jiawei Wang Date: Wed, 20 Jan 2021 08:50:17 +0200 Subject: [PATCH] app/testpmd: fix packets dump overlapping [ upstream commit 2ce964954b44aa87926052a7b018605e2a19eacd ] When testpmd enabled the verbosity for the received packets, if two packets were received at the same time, for example, sampling packet and normal packet, the dump output of these packets may be overlapping due to multiple core handling the multiple queues simultaneously. The patch uses one string buffer that collects all the packet dump output into this buffer and then printouts it at last, that guarantees to printout separately the dump output per packet. Fixes: d862c45b5955 ("app/testpmd: move dumping packets to a separate function") Signed-off-by: Jiawei Wang Acked-by: Viacheslav Ovsiienko Reviewed-by: Ferruh Yigit --- app/test-pmd/util.c | 175 +++++++++++++++++++++++++++++--------------- 1 file changed, 115 insertions(+), 60 deletions(-) diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c index 649bf8f53a..a9e431a8b2 100644 --- a/app/test-pmd/util.c +++ b/app/test-pmd/util.c @@ -15,12 +15,23 @@ #include "testpmd.h" +#define MAX_STRING_LEN 8192 + +#define MKDUMPSTR(buf, buf_size, cur_len, ...) \ +do { \ + if (cur_len >= buf_size) \ + break; \ + cur_len += snprintf(buf + cur_len, buf_size - cur_len, __VA_ARGS__); \ +} while (0) + static inline void -print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr) +print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr, + char print_buf[], size_t buf_size, size_t *cur_len) { char buf[RTE_ETHER_ADDR_FMT_SIZE]; + rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, eth_addr); - printf("%s%s", what, buf); + MKDUMPSTR(print_buf, buf_size, *cur_len, "%s%s", what, buf); } static inline bool @@ -74,13 +85,15 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], uint32_t vx_vni; const char *reason; int dynf_index; + char print_buf[MAX_STRING_LEN]; + size_t buf_size = MAX_STRING_LEN; + size_t cur_len = 0; if (!nb_pkts) return; - printf("port %u/queue %u: %s %u packets\n", - port_id, queue, - is_rx ? "received" : "sent", - (unsigned int) nb_pkts); + MKDUMPSTR(print_buf, buf_size, cur_len, + "port %u/queue %u: %s %u packets\n", port_id, queue, + is_rx ? "received" : "sent", (unsigned int) nb_pkts); for (i = 0; i < nb_pkts; i++) { int ret; struct rte_flow_error error; @@ -93,95 +106,128 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type); ret = rte_flow_get_restore_info(port_id, mb, &info, &error); if (!ret) { - printf("restore info:"); + MKDUMPSTR(print_buf, buf_size, cur_len, + "restore info:"); if (info.flags & RTE_FLOW_RESTORE_INFO_TUNNEL) { struct port_flow_tunnel *port_tunnel; port_tunnel = port_flow_locate_tunnel (port_id, &info.tunnel); - printf(" - tunnel"); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - tunnel"); if (port_tunnel) - printf(" #%u", port_tunnel->id); + MKDUMPSTR(print_buf, buf_size, cur_len, + " #%u", port_tunnel->id); else - printf(" %s", "-none-"); - printf(" type %s", - port_flow_tunnel_type(&info.tunnel)); + MKDUMPSTR(print_buf, buf_size, cur_len, + " %s", "-none-"); + MKDUMPSTR(print_buf, buf_size, cur_len, + " type %s", port_flow_tunnel_type + (&info.tunnel)); } else { - printf(" - no tunnel info"); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - no tunnel info"); } if (info.flags & RTE_FLOW_RESTORE_INFO_ENCAPSULATED) - printf(" - outer header present"); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - outer header present"); else - printf(" - no outer header"); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - no outer header"); if (info.flags & RTE_FLOW_RESTORE_INFO_GROUP_ID) - printf(" - miss group %u", info.group_id); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - miss group %u", info.group_id); else - printf(" - no miss group"); - printf("\n"); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - no miss group"); + MKDUMPSTR(print_buf, buf_size, cur_len, "\n"); } - print_ether_addr(" src=", ð_hdr->s_addr); - print_ether_addr(" - dst=", ð_hdr->d_addr); - printf(" - type=0x%04x - length=%u - nb_segs=%d", - eth_type, (unsigned int) mb->pkt_len, - (int)mb->nb_segs); + print_ether_addr(" src=", ð_hdr->s_addr, + print_buf, buf_size, &cur_len); + print_ether_addr(" - dst=", ð_hdr->d_addr, + print_buf, buf_size, &cur_len); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - type=0x%04x - length=%u - nb_segs=%d", + eth_type, (unsigned int) mb->pkt_len, + (int)mb->nb_segs); ol_flags = mb->ol_flags; if (ol_flags & PKT_RX_RSS_HASH) { - printf(" - RSS hash=0x%x", (unsigned int) mb->hash.rss); - printf(" - RSS queue=0x%x", (unsigned int) queue); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - RSS hash=0x%x", + (unsigned int) mb->hash.rss); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - RSS queue=0x%x", (unsigned int) queue); } if (ol_flags & PKT_RX_FDIR) { - printf(" - FDIR matched "); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - FDIR matched "); if (ol_flags & PKT_RX_FDIR_ID) - printf("ID=0x%x", - mb->hash.fdir.hi); + MKDUMPSTR(print_buf, buf_size, cur_len, + "ID=0x%x", mb->hash.fdir.hi); else if (ol_flags & PKT_RX_FDIR_FLX) - printf("flex bytes=0x%08x %08x", - mb->hash.fdir.hi, mb->hash.fdir.lo); + MKDUMPSTR(print_buf, buf_size, cur_len, + "flex bytes=0x%08x %08x", + mb->hash.fdir.hi, mb->hash.fdir.lo); else - printf("hash=0x%x ID=0x%x ", - mb->hash.fdir.hash, mb->hash.fdir.id); + MKDUMPSTR(print_buf, buf_size, cur_len, + "hash=0x%x ID=0x%x ", + mb->hash.fdir.hash, mb->hash.fdir.id); } if (is_timestamp_enabled(mb)) - printf(" - timestamp %"PRIu64" ", get_timestamp(mb)); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - timestamp %"PRIu64" ", get_timestamp(mb)); if (ol_flags & PKT_RX_QINQ) - printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x", - mb->vlan_tci, mb->vlan_tci_outer); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x", + mb->vlan_tci, mb->vlan_tci_outer); else if (ol_flags & PKT_RX_VLAN) - printf(" - VLAN tci=0x%x", mb->vlan_tci); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - VLAN tci=0x%x", mb->vlan_tci); if (!is_rx && (ol_flags & PKT_TX_DYNF_METADATA)) - printf(" - Tx metadata: 0x%x", - *RTE_FLOW_DYNF_METADATA(mb)); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - Tx metadata: 0x%x", + *RTE_FLOW_DYNF_METADATA(mb)); if (is_rx && (ol_flags & PKT_RX_DYNF_METADATA)) - printf(" - Rx metadata: 0x%x", - *RTE_FLOW_DYNF_METADATA(mb)); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - Rx metadata: 0x%x", + *RTE_FLOW_DYNF_METADATA(mb)); for (dynf_index = 0; dynf_index < 64; dynf_index++) { if (dynf_names[dynf_index][0] != '\0') - printf(" - dynf %s: %d", - dynf_names[dynf_index], - !!(ol_flags & (1UL << dynf_index))); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - dynf %s: %d", + dynf_names[dynf_index], + !!(ol_flags & (1UL << dynf_index))); } if (mb->packet_type) { rte_get_ptype_name(mb->packet_type, buf, sizeof(buf)); - printf(" - hw ptype: %s", buf); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - hw ptype: %s", buf); } sw_packet_type = rte_net_get_ptype(mb, &hdr_lens, RTE_PTYPE_ALL_MASK); rte_get_ptype_name(sw_packet_type, buf, sizeof(buf)); - printf(" - sw ptype: %s", buf); + MKDUMPSTR(print_buf, buf_size, cur_len, " - sw ptype: %s", buf); if (sw_packet_type & RTE_PTYPE_L2_MASK) - printf(" - l2_len=%d", hdr_lens.l2_len); + MKDUMPSTR(print_buf, buf_size, cur_len, " - l2_len=%d", + hdr_lens.l2_len); if (sw_packet_type & RTE_PTYPE_L3_MASK) - printf(" - l3_len=%d", hdr_lens.l3_len); + MKDUMPSTR(print_buf, buf_size, cur_len, " - l3_len=%d", + hdr_lens.l3_len); if (sw_packet_type & RTE_PTYPE_L4_MASK) - printf(" - l4_len=%d", hdr_lens.l4_len); + MKDUMPSTR(print_buf, buf_size, cur_len, " - l4_len=%d", + hdr_lens.l4_len); if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK) - printf(" - tunnel_len=%d", hdr_lens.tunnel_len); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - tunnel_len=%d", hdr_lens.tunnel_len); if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK) - printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - inner_l2_len=%d", hdr_lens.inner_l2_len); if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK) - printf(" - inner_l3_len=%d", hdr_lens.inner_l3_len); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - inner_l3_len=%d", hdr_lens.inner_l3_len); if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK) - printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - inner_l4_len=%d", hdr_lens.inner_l4_len); if (is_encapsulation) { struct rte_ipv4_hdr *ipv4_hdr; struct rte_ipv6_hdr *ipv6_hdr; @@ -218,18 +264,27 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], l2_len + l3_len + l4_len); udp_port = RTE_BE_TO_CPU_16(udp_hdr->dst_port); vx_vni = rte_be_to_cpu_32(vxlan_hdr->vx_vni); - printf(" - VXLAN packet: packet type =%d, " - "Destination UDP port =%d, VNI = %d", - packet_type, udp_port, vx_vni >> 8); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - VXLAN packet: packet type =%d, " + "Destination UDP port =%d, VNI = %d", + packet_type, udp_port, vx_vni >> 8); } } - printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send", - (unsigned int) queue); - printf("\n"); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - %s queue=0x%x", is_rx ? "Receive" : "Send", + (unsigned int) queue); + MKDUMPSTR(print_buf, buf_size, cur_len, "\n"); rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf)); - printf(" ol_flags: %s\n", buf); + MKDUMPSTR(print_buf, buf_size, cur_len, + " ol_flags: %s\n", buf); if (rte_mbuf_check(mb, 1, &reason) < 0) - printf("INVALID mbuf: %s\n", reason); + MKDUMPSTR(print_buf, buf_size, cur_len, + "INVALID mbuf: %s\n", reason); + if (cur_len >= buf_size) + printf("%s ...\n", print_buf); + else + printf("%s", print_buf); + cur_len = 0; } } -- 2.29.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-05 11:18:39.002228974 +0000 +++ 0223-app-testpmd-fix-packets-dump-overlapping.patch 2021-02-05 11:18:29.178698194 +0000 @@ -1 +1 @@ -From 2ce964954b44aa87926052a7b018605e2a19eacd Mon Sep 17 00:00:00 2001 +From 016bb40b6cf6211ea64bef22065b9454a95c681d Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 2ce964954b44aa87926052a7b018605e2a19eacd ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org