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 4B137457D7; Thu, 15 Aug 2024 16:21:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E17A04275C; Thu, 15 Aug 2024 16:21:06 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id DCEA940647 for ; Thu, 15 Aug 2024 16:21:05 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D78D414BF; Thu, 15 Aug 2024 07:21:30 -0700 (PDT) Received: from e132423.cambridge.arm.com (e132423.arm.com [10.1.38.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 005123F73B; Thu, 15 Aug 2024 07:21:02 -0700 (PDT) From: Alex Chapman To: dev@dpdk.org Cc: Aman Singh , Jeremy Spewock , Honnappa Nagarahalli , =?UTF-8?q?Juraj=20Linke=C5=A1?= , Alex Chapman , Luca Vizzarro , Paul Szczepanek Subject: [PATCH] app/testpmd: add L4 port to verbose output Date: Thu, 15 Aug 2024 15:20:51 +0100 Message-Id: <20240815142051.531978-1-alex.chapman@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 To help distinguish packets we want to add more identifiable information and print port number for all packets. This will make packet metadata more uniform as previously it only printed port number for encapsulated packets. Bugzilla-ID: 1517 Signed-off-by: Alex Chapman Reviewed-by: Luca Vizzarro Reviewed-by: Paul Szczepanek --- app/test-pmd/util.c | 71 +++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c index bf9b639d95..5fa05fad16 100644 --- a/app/test-pmd/util.c +++ b/app/test-pmd/util.c @@ -81,7 +81,6 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], char buf[256]; struct rte_net_hdr_lens hdr_lens; uint32_t sw_packet_type; - uint16_t udp_port; uint32_t vx_vni; const char *reason; int dynf_index; @@ -234,49 +233,63 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK) 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; - struct rte_udp_hdr *udp_hdr; - uint8_t l2_len; - uint8_t l3_len; - uint8_t l4_len; - uint8_t l4_proto; - struct rte_vxlan_hdr *vxlan_hdr; - - l2_len = sizeof(struct rte_ether_hdr); - - /* Do not support ipv4 option field */ - if (RTE_ETH_IS_IPV4_HDR(packet_type)) { - l3_len = sizeof(struct rte_ipv4_hdr); - ipv4_hdr = rte_pktmbuf_mtod_offset(mb, + + struct rte_ipv4_hdr *ipv4_hdr; + struct rte_ipv6_hdr *ipv6_hdr; + struct rte_udp_hdr *udp_hdr; + struct rte_tcp_hdr *tcp_hdr; + uint8_t l2_len; + uint8_t l3_len; + uint8_t l4_len; + uint8_t l4_proto; + uint16_t l4_port; + struct rte_vxlan_hdr *vxlan_hdr; + + l2_len = sizeof(struct rte_ether_hdr); + + /* Do not support ipv4 option field */ + if (RTE_ETH_IS_IPV4_HDR(packet_type)) { + l3_len = sizeof(struct rte_ipv4_hdr); + ipv4_hdr = rte_pktmbuf_mtod_offset(mb, struct rte_ipv4_hdr *, l2_len); - l4_proto = ipv4_hdr->next_proto_id; - } else { - l3_len = sizeof(struct rte_ipv6_hdr); - ipv6_hdr = rte_pktmbuf_mtod_offset(mb, + l4_proto = ipv4_hdr->next_proto_id; + } else { + l3_len = sizeof(struct rte_ipv6_hdr); + ipv6_hdr = rte_pktmbuf_mtod_offset(mb, struct rte_ipv6_hdr *, l2_len); - l4_proto = ipv6_hdr->proto; - } - if (l4_proto == IPPROTO_UDP) { - udp_hdr = rte_pktmbuf_mtod_offset(mb, + l4_proto = ipv6_hdr->proto; + } + if (l4_proto == IPPROTO_UDP) { + udp_hdr = rte_pktmbuf_mtod_offset(mb, struct rte_udp_hdr *, l2_len + l3_len); + l4_port = RTE_BE_TO_CPU_16(udp_hdr->dst_port); + if (is_encapsulation) { l4_len = sizeof(struct rte_udp_hdr); vxlan_hdr = rte_pktmbuf_mtod_offset(mb, - struct rte_vxlan_hdr *, - l2_len + l3_len + l4_len); - udp_port = RTE_BE_TO_CPU_16(udp_hdr->dst_port); + struct rte_vxlan_hdr *, + l2_len + l3_len + l4_len); vx_vni = rte_be_to_cpu_32(vxlan_hdr->vx_vni); MKDUMPSTR(print_buf, buf_size, cur_len, " - VXLAN packet: packet type =%d, " "Destination UDP port =%d, VNI = %d, " "last_rsvd = %d", packet_type, - udp_port, vx_vni >> 8, vx_vni & 0xff); + l4_port, vx_vni >> 8, vx_vni & 0xff); + } else { + MKDUMPSTR(print_buf, buf_size, cur_len, + " - Destination UDP port=%d", l4_port); } + } else if (l4_proto == IPPROTO_TCP) { + tcp_hdr = rte_pktmbuf_mtod_offset(mb, + struct rte_tcp_hdr *, + l2_len + l3_len); + l4_port = RTE_BE_TO_CPU_16(tcp_hdr->dst_port); + MKDUMPSTR(print_buf, buf_size, cur_len, + " - Destination TCP port=%d", l4_port); } + MKDUMPSTR(print_buf, buf_size, cur_len, " - %s queue=0x%x", is_rx ? "Receive" : "Send", (unsigned int) queue); -- 2.34.1