From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0041.outbound.protection.outlook.com [104.47.1.41]) by dpdk.org (Postfix) with ESMTP id 903255F4D for ; Wed, 17 Oct 2018 09:27:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iE367GY2uGyFml2YHWLaj7lAEoHEZtu3G2NEaWQ1bEc=; b=AAR//Ae7At2lPDD/aWZ2yYADs4PZ2WBId69ZKn8xjJsGyE6Ebs1wksJ2WRD4aR8XA0WfTfydl4NXX7mpXUbMng15v9PC7wnINS3za6SUcgO94T33UrsN3N9W58fUMqRESvR2rpc5Rc1Bb9eiEFuDpuxP4CuWiMjjfC2qvXNId+s= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; Received: from mellanox.com (37.142.13.130) by DB5PR05MB1253.eurprd05.prod.outlook.com (2a01:111:e400:51cb::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.23; Wed, 17 Oct 2018 07:27:40 +0000 From: Raslan Darawsheh To: jingjing.wu@intel.com Cc: thomas@monjalon.net, dev@dpdk.org, shahafs@mellanox.com, rasland@mellanox.com, xuemingl@mellanox.com, orika@mellanox.com, jerin.jacob@caviumnetworks.com, david.marchand@6wind.com, bernard.iremonger@intel.com, ferruh.yigit@intel.com Date: Wed, 17 Oct 2018 10:27:29 +0300 Message-Id: <1539761251-7677-1-git-send-email-rasland@mellanox.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538897848-1693-1-git-send-email-rasland@mellanox.com> References: <1538897848-1693-1-git-send-email-rasland@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: CWLP265CA0322.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:57::22) To DB5PR05MB1253.eurprd05.prod.outlook.com (2a01:111:e400:51cb::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5a3267f7-e1cf-4210-65f0-08d6340205dd X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB5PR05MB1253; X-Microsoft-Exchange-Diagnostics: 1; DB5PR05MB1253; 3:icLfWFeNH0cYdT0GhmPjgkhlTXrKbq0qj9wn12B56pQT1D+Jb6xkhKiVHqrzRlvEFysy4VT0wbLlc/c4iZ/A/DQcJBZsNUX8XzpS27oUg/Nlw/XxQNJ94pP5E8mstXuKqedyYi7TwDJPUDSpjl8ZdolSTFJWgwjr0tSlYSXI9UiJKNxeyw+hwpArY22cx+rnsO0maJujy22SMZfoUeXydYolI2Dd8tyPLqh/2wRntWEafmIMNJ4vUQRXGy9UGOx7; 25:zKvRQWJSz5ZGu9aGJ88++WfLJ6jN5uWhRNrmorK3crXXWMw3ZXrELPwpafUHHkTjzIm+kWBQAgKK6x6UB5UC7M37SmbfXzRITHpw0Mm0JKkgBcJEfhfM+KHZ6F8dN/qdoEdegGsIwlxYZUCTirrjJVQ3KBHQp+dpJKknQm/T+gNjZ2f7F52qd3iM9c7blAxDrjWS3HiNIap+wE+ws6RIO+mP4fbwXnZ258kTdkQ/kmGUpLhYckCkZagDkVIN8Vnn/jJivl8aAbWPdWsvDx0r6PehM7Zxa5wgXNTPcWo8YGSfvAKUhjMgnf3XzNuAMj2qbKsFd0kQ93aSp85hMWnPHFXAvLeT1wF9ytqwSnKr4zo=; 31:6YlwpS/fo+4YshZvdxfe68j1A9zZey/Cq2X0NJ4uOaMw/0iOSrVc8lUBRd3fQ/aUl0T6nbdUaefFe0DnZB5AeQSF3HZnZRRLYBTvdEJpK2aobAwCebd44FH3M3UGwq3ariDFxRcoLIGYPWponCLcAoZ+3E9+AiDPPaZMCg+epQFbnxuIBfKAySwQBsoCyDUcASCAGm9Y80pULzchDAj/467hRliOlw/T/NRM/Rp/d/w= X-MS-TrafficTypeDiagnostic: DB5PR05MB1253: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; DB5PR05MB1253; 20:MhUNK795BDckunKaGiYqAf003vJisoS7+MVMvw7CQLrZ/Dk1jf7R42zwG8N6+r9Zkn3ypISYudIvklbVkafhnru55y24MWae9jULmX+nQ8Sx5vY/FyMOlJdVGti3+fhRtcKrnHivYLRbqZrThTP87KoSSU1RkhGcl4SaMv1THrM0fNDH4f1mfoC+CFpsGfW+lX2Ht8PS2YRrsJYBXAR7LlmpAXwJCAKcEtDIMmRqZXROIzz0lsofhcKj6/IyBrw6QI9Nzdo+oB0vxkbKSxbwTbGe/IZkm0ZOJnlThFL8qeL4361hZR+YOiGIoHjL4X9h4Nk6yCHCIv3RnZ2LEGANBlEmLcrUhSorHceZlcvkdenSq88a76meZw1Piiqsg1ASfnDNHGj9fdir2d9k6qYENXQ/g6+H2EzRBTfWfUr5SKFVkfSjPKIAwvm5BksDCEL6WvpNlnN6hZ5FNBAHCRCUNirKhfeyygcm9WSQ17ndVs/Lr2LLIsRzDns0U+KPuU4G; 4:cjZbIf3Ya3YtQs+dfFroD2DIhKymJJyl0vbjHYsLRXo9R3Npcx7MUqe9qGrrN4/MH43nYoGBzYDxvlcxy6Ed1GaGGp3MbRzozcBdBTZ3k1LIcKy9TYyVjJmIYMugnlwevJKqRxBNVlvXAlSIdLehzbfuZFp+xgibjB5lYQkxQJrVO8mubmHYMNdxm46BYKUH4+jDlpW0luE3DWN/3scnI46FBU17ZPelta7dupdm8PHwsmz5KC9L2mvYHmAy6Z7Kekggkr5mYLKVhPlmzA61e9/vy+Tp4IorF0oOAm7/MgdaK6kzmfUoCn7owTT5/vps X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:DB5PR05MB1253; BCL:0; PCL:0; RULEID:; SRVR:DB5PR05MB1253; X-Forefront-PRVS: 08286A0BE2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(346002)(136003)(39860400002)(376002)(366004)(199004)(189003)(33026002)(476003)(97736004)(50466002)(48376002)(55016002)(50226002)(16586007)(4744004)(11346002)(21086003)(105586002)(36756003)(3846002)(106356001)(6116002)(446003)(2616005)(956004)(68736007)(69596002)(316002)(4326008)(2361001)(2351001)(7736002)(6666004)(53936002)(47776003)(25786009)(305945005)(66066001)(486006)(186003)(7696005)(52116002)(16526019)(81156014)(2906002)(26005)(8886007)(8676002)(86362001)(5660300001)(575784001)(386003)(81166006)(478600001)(6916009)(76176011)(8936002)(51416003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR05MB1253; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB5PR05MB1253; 23:F+2WJQLUet75M+R7FScLfBBvd67BsupZv+p8yEVtm?= =?us-ascii?Q?C8J0wD784VfCQDGOvgwOTdHZWiwut2wjKdIBsUdSX9zP0y/v7xpcoOqjweoo?= =?us-ascii?Q?4WZIx+kbfWhyNehx4AvGPbOii6qrWSHtCLwKKSRM2n8gQRI1u9YbiRQLKETz?= =?us-ascii?Q?D8eK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+4AxB6CANs4FuphcXTpBePfq6eq2I+sVwPWA2+hUvr/KMMKpuTPxDcATU7o3wFcA+1h2lvIOH06lwxAihB56Ze01MpKFreOhS8XAMxRAc98dkLhAfY99FebVXkxkpA2zg6Xe/ekM6uQ5OSHL2ZktP7s74EsGT4ypj484FfZN7A==; 5:fSrANlRdc4Cn3qBiKmoAEi98fVPGKbyn/UB10EjEFJ0yGFLfKWmoG12N2Lnr6lj7wKeVqv4KqWccGZjl+bu8vdqVe64b5NZ/a8oWWz36Fbh8XnJQ1/WL787dG6fJQGCAqaPW1lv4cPnbA2yyKytaw7OVytiSNiGRHS2DFsO5SS4=; 7:0OnTEMqul1WFavufHn/AWn+Kaqyh5XJ/KtZ9fP9dTjHeRLlPlIXvHdlUNUVi1VFT1b4gF4mLz9bviwbQFO5nauTUDY9x5OVrgF4zG4yUaun1METkhdd+CYCDSgHTIR3zBUEAxEpjSxEngQ2nmxp6DkXxsO7DGrhtlNFhPILejK2JhF+ZOnLPLWwzqCWQAIPDu0Gis1Y02D6qnr3af0svqGknllZz21bA+LuGr3yLE4aYkpOAT9yF2oPN5fAX/QEi SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2018 07:27:40.1819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a3267f7-e1cf-4210-65f0-08d6340205dd X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR05MB1253 Subject: [dpdk-dev] [PATCH v5 1/3] app/testpmd: move dumping packets to a separate function 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: , X-List-Received-Date: Wed, 17 Oct 2018 07:27:45 -0000 verbosity for the received/sent packets is needed in all of the forwarding engines so moving it to be in a separate function Acked-by: Bernard Iremonger Signed-off-by: Raslan Darawsheh --- changes in v5: fix alligning convention fix copyright --- --- app/test-pmd/Makefile | 1 + app/test-pmd/meson.build | 3 +- app/test-pmd/rxonly.c | 134 +---------------------------------------- app/test-pmd/util.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+), 132 deletions(-) create mode 100644 app/test-pmd/util.c diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile index e2581ca..8e4ff5b 100644 --- a/app/test-pmd/Makefile +++ b/app/test-pmd/Makefile @@ -36,6 +36,7 @@ SRCS-y += icmpecho.c SRCS-y += noisy_vnf.c SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c SRCS-$(CONFIG_RTE_LIBRTE_BPF) += bpf_cmd.c +SRCS-y += util.c ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC), y) SRCS-y += softnicfwd.c diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build index 9ef6ed9..cd66618 100644 --- a/app/test-pmd/meson.build +++ b/app/test-pmd/meson.build @@ -21,7 +21,8 @@ sources = files('cmdline.c', 'parameters.c', 'rxonly.c', 'testpmd.c', - 'txonly.c') + 'txonly.c', + 'util.c') deps = ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter', 'bus_pci'] if dpdk_conf.has('RTE_LIBRTE_PDUMP') diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index 41db0ff..3eca89c 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -40,14 +40,6 @@ #include "testpmd.h" -static inline void -print_ether_addr(const char *what, struct ether_addr *eth_addr) -{ - char buf[ETHER_ADDR_FMT_SIZE]; - ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr); - printf("%s%s", what, buf); -} - /* * Received a burst of packets. */ @@ -55,16 +47,8 @@ static void pkt_burst_receive(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; - struct rte_mbuf *mb; - struct ether_hdr *eth_hdr; - uint16_t eth_type; - uint64_t ol_flags; uint16_t nb_rx; - uint16_t i, packet_type; - uint16_t is_encapsulation; - char buf[256]; - struct rte_net_hdr_lens hdr_lens; - uint32_t sw_packet_type; + uint16_t i; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES uint64_t start_tsc; @@ -90,120 +74,8 @@ pkt_burst_receive(struct fwd_stream *fs) /* * Dump each received packet if verbose_level > 0. */ - if (verbose_level > 0) - printf("port %u/queue %u: received %u packets\n", - fs->rx_port, - (unsigned) fs->rx_queue, - (unsigned) nb_rx); - for (i = 0; i < nb_rx; i++) { - mb = pkts_burst[i]; - if (verbose_level == 0) { - rte_pktmbuf_free(mb); - continue; - } - eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *); - eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type); - ol_flags = mb->ol_flags; - packet_type = mb->packet_type; - is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type); - - 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) mb->pkt_len, - (int)mb->nb_segs); - if (ol_flags & PKT_RX_RSS_HASH) { - printf(" - RSS hash=0x%x", (unsigned) mb->hash.rss); - printf(" - RSS queue=0x%x",(unsigned) fs->rx_queue); - } - if (ol_flags & PKT_RX_FDIR) { - printf(" - FDIR matched "); - if (ol_flags & PKT_RX_FDIR_ID) - printf("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); - else - printf("hash=0x%x ID=0x%x ", - mb->hash.fdir.hash, mb->hash.fdir.id); - } - if (ol_flags & PKT_RX_TIMESTAMP) - printf(" - timestamp %"PRIu64" ", mb->timestamp); - if (ol_flags & PKT_RX_QINQ) - printf(" - 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); - if (mb->packet_type) { - rte_get_ptype_name(mb->packet_type, buf, sizeof(buf)); - printf(" - 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); - if (sw_packet_type & RTE_PTYPE_L2_MASK) - printf(" - l2_len=%d", hdr_lens.l2_len); - if (sw_packet_type & RTE_PTYPE_L3_MASK) - printf(" - l3_len=%d", hdr_lens.l3_len); - if (sw_packet_type & RTE_PTYPE_L4_MASK) - printf(" - l4_len=%d", hdr_lens.l4_len); - if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK) - printf(" - 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); - if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK) - printf(" - 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); - if (is_encapsulation) { - struct ipv4_hdr *ipv4_hdr; - struct ipv6_hdr *ipv6_hdr; - struct udp_hdr *udp_hdr; - uint8_t l2_len; - uint8_t l3_len; - uint8_t l4_len; - uint8_t l4_proto; - struct vxlan_hdr *vxlan_hdr; - - l2_len = sizeof(struct ether_hdr); - - /* Do not support ipv4 option field */ - if (RTE_ETH_IS_IPV4_HDR(packet_type)) { - l3_len = sizeof(struct ipv4_hdr); - ipv4_hdr = rte_pktmbuf_mtod_offset(mb, - struct ipv4_hdr *, - l2_len); - l4_proto = ipv4_hdr->next_proto_id; - } else { - l3_len = sizeof(struct ipv6_hdr); - ipv6_hdr = rte_pktmbuf_mtod_offset(mb, - struct ipv6_hdr *, - l2_len); - l4_proto = ipv6_hdr->proto; - } - if (l4_proto == IPPROTO_UDP) { - udp_hdr = rte_pktmbuf_mtod_offset(mb, - struct udp_hdr *, - l2_len + l3_len); - l4_len = sizeof(struct udp_hdr); - vxlan_hdr = rte_pktmbuf_mtod_offset(mb, - struct vxlan_hdr *, - l2_len + l3_len + l4_len); - - printf(" - VXLAN packet: packet type =%d, " - "Destination UDP port =%d, VNI = %d", - packet_type, RTE_BE_TO_CPU_16(udp_hdr->dst_port), - rte_be_to_cpu_32(vxlan_hdr->vx_vni) >> 8); - } - } - printf(" - Receive queue=0x%x", (unsigned) fs->rx_queue); - printf("\n"); - rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf)); - printf(" ol_flags: %s\n", buf); - rte_pktmbuf_free(mb); - } + for (i = 0; i < nb_rx; i++) + rte_pktmbuf_free(pkts_burst[i]); #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES end_tsc = rte_rdtsc(); diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c new file mode 100644 index 0000000..4fcb2f9 --- /dev/null +++ b/app/test-pmd/util.c @@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation + * Copyright(c) 2018 Mellanox Technology + */ + +#include + +#include +#include +#include +#include +#include + +#include "testpmd.h" + +static inline void +print_ether_addr(const char *what, struct ether_addr *eth_addr) +{ + char buf[ETHER_ADDR_FMT_SIZE]; + ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr); + printf("%s%s", what, buf); +} + +static inline void +dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], + uint16_t nb_pkts, int is_rx) +{ + struct rte_mbuf *mb; + struct ether_hdr *eth_hdr; + uint16_t eth_type; + uint64_t ol_flags; + uint16_t i, packet_type; + uint16_t is_encapsulation; + char buf[256]; + struct rte_net_hdr_lens hdr_lens; + uint32_t sw_packet_type; + uint16_t udp_port; + uint32_t vx_vni; + + if (!nb_pkts) + return; + printf("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++) { + mb = pkts[i]; + eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *); + eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type); + ol_flags = mb->ol_flags; + packet_type = mb->packet_type; + is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type); + + 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); + 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); + } + if (ol_flags & PKT_RX_FDIR) { + printf(" - FDIR matched "); + if (ol_flags & PKT_RX_FDIR_ID) + printf("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); + else + printf("hash=0x%x ID=0x%x ", + mb->hash.fdir.hash, mb->hash.fdir.id); + } + if (ol_flags & PKT_RX_TIMESTAMP) + printf(" - timestamp %"PRIu64" ", mb->timestamp); + if (ol_flags & PKT_RX_QINQ) + printf(" - 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); + if (mb->packet_type) { + rte_get_ptype_name(mb->packet_type, buf, sizeof(buf)); + printf(" - 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); + if (sw_packet_type & RTE_PTYPE_L2_MASK) + printf(" - l2_len=%d", hdr_lens.l2_len); + if (sw_packet_type & RTE_PTYPE_L3_MASK) + printf(" - l3_len=%d", hdr_lens.l3_len); + if (sw_packet_type & RTE_PTYPE_L4_MASK) + printf(" - l4_len=%d", hdr_lens.l4_len); + if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK) + printf(" - 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); + if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK) + printf(" - 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); + if (is_encapsulation) { + struct ipv4_hdr *ipv4_hdr; + struct ipv6_hdr *ipv6_hdr; + struct udp_hdr *udp_hdr; + uint8_t l2_len; + uint8_t l3_len; + uint8_t l4_len; + uint8_t l4_proto; + struct vxlan_hdr *vxlan_hdr; + + l2_len = sizeof(struct ether_hdr); + + /* Do not support ipv4 option field */ + if (RTE_ETH_IS_IPV4_HDR(packet_type)) { + l3_len = sizeof(struct ipv4_hdr); + ipv4_hdr = rte_pktmbuf_mtod_offset(mb, + struct ipv4_hdr *, + l2_len); + l4_proto = ipv4_hdr->next_proto_id; + } else { + l3_len = sizeof(struct ipv6_hdr); + ipv6_hdr = rte_pktmbuf_mtod_offset(mb, + struct ipv6_hdr *, + l2_len); + l4_proto = ipv6_hdr->proto; + } + if (l4_proto == IPPROTO_UDP) { + udp_hdr = rte_pktmbuf_mtod_offset(mb, + struct udp_hdr *, + l2_len + l3_len); + l4_len = sizeof(struct udp_hdr); + vxlan_hdr = rte_pktmbuf_mtod_offset(mb, + struct vxlan_hdr *, + 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); + } + } + printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send", + (unsigned int) queue); + printf("\n"); + rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf)); + printf(" ol_flags: %s\n", buf); + } +} -- 2.7.4