From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40086.outbound.protection.outlook.com [40.107.4.86]) by dpdk.org (Postfix) with ESMTP id 57D931041 for ; Wed, 12 Sep 2018 10:06:35 +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=Ag6h2vFsrfOd95+e/k5oJ4p11AsAoGHaF6aLyBM+Gx8=; b=pKGgoMwYt5XdMxxRauo9Xl9nL/EGotcZIeKnSdU4IcDsLE7MLEGpSGD4Q5t5HTRJztnCpMcQK0SK9fMHexhueoGIz033l6xiIJTmE8ltKMlCWOCJJGdBaYbqi3t24pj3SF8+NZsj4L4mtaMHyBFkDFfMoMYE/Q5ZTuZPoXXVex4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; Received: from mellanox.com (37.142.13.130) by DB5PR05MB1255.eurprd05.prod.outlook.com (2a01:111:e400:51cc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.15; Wed, 12 Sep 2018 08:06:33 +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 Date: Wed, 12 Sep 2018 11:06:22 +0300 Message-Id: <1536739583-29166-1-git-send-email-rasland@mellanox.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: LO2P265CA0118.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::34) To DB5PR05MB1255.eurprd05.prod.outlook.com (2a01:111:e400:51cc::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ba6b553-ef62-4b23-ffc7-08d61886a7da X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB5PR05MB1255; X-Microsoft-Exchange-Diagnostics: 1; DB5PR05MB1255; 3:q8AoadoX03NwvLwA4bApflsAHFPL9xj+ZVi4RPLuWF0M7QU02gWfrl5rFzrFFhWDVgBOov0mNky2bWCwAgvWLcqeEzrcqbvN9VwXEZ97CCCsrPtHO5BQ/nFxDqK7/vQAzb53+AyEE6sRlTMK9gLjDhlVsqQzgl0DbiFeIr6ITjM2HR+FJCokE/L6z8xvhadpcuPrxaB7zQP16olkC3wD7OFw3hnpkX13C0spTtW+xXhg+hsOZFnGqZOrtIiVYZaU; 25:np2wLCwhU6zkcfZhbP4QyzYMNyfIwEto+bOMMBtHHLESLkdMgPCz8GZnjSu96WaHIW28l0FTw7inqpCqJ5SN3dIhZyXa2G52A/6IZFU7FIiuGx/zuYGC5GggbUPsWrg4gu0sZtGhWuIbcdhZmXO50dmp8hwulEBx2lV2ncpehETX6v2yFMIG3ii+PrAPRG5LIKph6O4dwM0TeGZHFQLPezqUBHIVt+2fvLa5e0hb/jvM4EgKBOwiJwyo7/M+eOZ49FygtcaL8xMo2AguWlQiU9Rzj+OP7ovgH2G5ut6hrfVoe1kmMcOsIIfJxBVMTv1wVyoU0mCrZLIETj+OJ5tKEQ==; 31:mG9o0roEV5PiV6ihEOR9DA4oBQbsNlBxz0MvPtRSSmkkGq5801f6diZxUcbvPi+U/LZgK9nSTN+0X9qWbyCRwCqF4mJqAZdwoL5zVFDRZU/qbdqy1ttJ0El4ttbiZfBxjlxfNbC9pK81UtQMxNHT5oGue67ApV+ywfyxJgPdJ0iClZ54QJZPA7EksjfjCudDHTLsjRe3whNn7gZKj/T8ZHe2aGzKSPZ9o37BZk65Pyw= X-MS-TrafficTypeDiagnostic: DB5PR05MB1255: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; DB5PR05MB1255; 20:5pUQa96bA6IF4QbcAqTZojp+/M8Cz+LBeXUrrShdPX+Ns3uQTUDlR+V4eT4qz3EJ1wujayaOiQVWdsJzg2toS0mZu8pjQCQXJwsg15uRXXxvbrLZD0HRkznsEi/W6KaxDzfzXdzz1N0N6VFqOqabxJbJ6evllekpMMVlbEHgcxMz/HprhqHoe5ziaR0bcP5vcYuFAfqFQbKMFIF7+17VH5HpibM8dYFbVX0LGhQwK9mKyPn3k0kEIa8G6oivoqZjoEq3l+SxZ0H2yjv7teghi5CkyG6ObC/JvFDbuJS5lIuhkAZL2BPv77oXVCAIOAv/oeWFbqcWT6WlmDVNcsE9FQTfdsoXb8HS7r+0twYNcE0YqRJQ2qHmYUoRBXvRTOzBjlrJuUVzjRSVtFSKSQDknqS9C6tan/Hp0LjU6EcteJx7a/Y6U8sH4w/EweA4ajXb76oFHCJdHHhl2vMgULrAeje5PdFYx/DgF8mDF15MxHowO2QfXE+hOkY9+hxh78nH; 4:gULT22URRY/AUll53vRAxYRylRuXcXYbPlD26AWgP8jFaMQ3ej8blQDi9FgtVvJHLUMUh4u8GpvXG1sKQemxlDf2i1dBNa/KcdJaRooRO3dWtDyVzs9nSgBDXrokupupoESakxeY+pM54lCmwbOUL7CWaeVlyglKPQbAFjkajm5v8Qd4YuDCLZ7NuszRdjepRV1Kh/i9GXOYtaWjct5d69iQ9osRDTaZ9wh35QZ4LHG9LKtVombJN/S5Z69z3igplnXybzdb1j3Sy/vWzdrR1g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3231311)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050); SRVR:DB5PR05MB1255; BCL:0; PCL:0; RULEID:; SRVR:DB5PR05MB1255; X-Forefront-PRVS: 07935ACF08 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(346002)(366004)(376002)(39860400002)(396003)(189003)(199004)(2906002)(386003)(33026002)(7736002)(69596002)(186003)(26005)(107886003)(25786009)(97736004)(478600001)(4326008)(8676002)(66066001)(16526019)(86362001)(575784001)(6116002)(3846002)(47776003)(5660300001)(16586007)(50226002)(36756003)(2351001)(55016002)(105586002)(106356001)(316002)(476003)(486006)(2616005)(21086003)(956004)(68736007)(52116002)(7696005)(2361001)(305945005)(6916009)(48376002)(81156014)(53936002)(51416003)(8936002)(50466002)(6666003)(81166006)(41533002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR05MB1255; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB5PR05MB1255; 23:/jEHtLpI8xcNOJN2sp53Vsr500vuNrq7ftrZrWpRt?= =?us-ascii?Q?uvMg8zIwNKE8/KBo9W4Z7YBvkiM1ZMjn8D8sBrzf1yOQuyHK9NwyIn4dh4ZI?= =?us-ascii?Q?rbb8nm4MJgd8jshk5D9y7gwi8dE9rJQ2KkNXpir6jL6i9zMLy/kzYr9mtd3h?= =?us-ascii?Q?5HZEQqMP5okgT8rJcLAIw7bQiPxvpOgKL6hJmCMbhpbvrOVqvVjdnaaoQJIT?= =?us-ascii?Q?k/HuTDHjhjYv0I4eiELGihJPJvaAkI62/yZEqNux1JQOe4hdj0QH+Bi9ZRWB?= =?us-ascii?Q?NDBRYUCcmNLb4n0PQoxqqjHk/9yMpVTR6I+vX0jW14zdCyQSRV18bThaHqQT?= =?us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EfYGCw4sjKumGv?= =?us-ascii?Q?NLhOF8OXY72jwcel52ByXu1piTTlCG/eMVz/a9K?= X-Microsoft-Antispam-Message-Info: IuGc2I+lljfRJ6bWnvQU6ZO1WvNbYAbCG4IGvW7gcURYj4+T4wJRhFWkgfqq81vUMT7RXp8jdEXF+cebLu7FMUtOk2KdpdWZ+WDCyxV2HgfDx87pvJLwih+JS8X580fngUGaS59NUOkLRxUyDz1kvKCi5b8RychShQnhrybrKeWUdXoBwJ7rXxIJa8V8K39bHa1CTE7h08TuJAeNtBgfNSjq+Rhax5sHobC8KYTYbVo6qqFmWAZ1sBOhl4NWXecRTIqY+GV06BnejtOzESdphUX7IbEnt8WomcoTObTIuoJdaVVigDwsUsGCfIRqxEq5+4Z3Knto1KBKlt5HATQyX2944OHfVLtpZ4oubX5wcTo= X-Microsoft-Exchange-Diagnostics: 1; DB5PR05MB1255; 6:fu8Aw9HLFNV+1EwOFYZGGNANA0HqQap6bVrBKlMjtCNgdexZiM7mXo2honMn6xf3Q5VZvgXE+yt4lMTT5XvPFRZi2yGE1oiq8wDuRNAmRtOwZjOh4uGMjmyUgT2tWoBnib0gErwysUkfNhWlWTG4jsEmQUPUHB5ntDGxQNk2y1tJy+gCU8XOwlhj/9Q7uM5Gkm6FDVMtzq8jHBEs3wdl9tKHLNJU+Z6bdwe/416OerJujzdHZp4aiBsMX88KZlyP7XDmmuEyYIi/YcF4NnEh/r5nkUZe81zQvBj7tY7UWWs9p/0Bw+y328CndlT+kzluQgLUXA62sAwAbRLe5ufV4R1drV578Z/P0NFhbXqG7nLFWoNBBUYZfiWctsLseh0/DG70bXorTplpMMpjo2p8i3OhSepMJCfNfvrd2WVQBZ3Sb4WxqmN6yb353S1n7axwbKK2tTGi/J0pyUa7wwp0Dg==; 5:27zlhxIb34FD68Pav+bzBgW745Nz/c4veTBWcp8XReHWyPibLAQzDJWthauhk/rQNd4nqFb5srUieSLW+dPGTsAVeokqRTezY8LA9JtzMz2x+31sOfGnkDIprIjd6lhqqDAtTp0IYZcbh9OHReVoJA/IWtKfjdObhuuPxf9q3yo=; 7:bz+ELGBW1KruoALyAt3XPr/RFqjLr82hvyaETxXPJQWeR+5yv7ZnROz8gNp9wP0PqO0UZaag40e6C30TYFg8Ry6pnsUbNTjHGFih4y2gDiiKPhsJFPDhjo0iBnhtDK6hUPl7b3Nlj6/Q5NZNap/266msNQ4AK2RFnPPA5U0hwH8Pcv6zdjJhVZ6udr4F6rvFNoB/PIbBoqYXXVIg/MkdsvG+7PXuwxXCZ/7hU2hQdlBb1mTxjk+8HhXhujiry9Js SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2018 08:06:33.1741 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ba6b553-ef62-4b23-ffc7-08d61886a7da X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR05MB1255 Subject: [dpdk-dev] [PATCH 1/2] app/testpmd: add a generic way for dumping packets 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, 12 Sep 2018 08:06:35 -0000 verbosity for the received/sent packets is needed in all of the forwarding engines so moving it to be in a separate function. Signed-off-by: Raslan Darawsheh --- app/test-pmd/Makefile | 1 + app/test-pmd/testpmd.h | 2 + app/test-pmd/util.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 app/test-pmd/util.c diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile index 2b4d604..e2c7845 100644 --- a/app/test-pmd/Makefile +++ b/app/test-pmd/Makefile @@ -35,6 +35,7 @@ SRCS-y += csumonly.c SRCS-y += icmpecho.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/testpmd.h b/app/test-pmd/testpmd.h index a1f6614..a0d9ce1 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -743,6 +743,8 @@ int check_nb_rxq(queueid_t rxq); queueid_t get_allowed_max_nb_txq(portid_t *pid); int check_nb_txq(queueid_t txq); +void dump_pkt_burst(struct fwd_stream *fs, struct rte_mbuf *pkts_burst[], + uint16_t nb_rx, int direction); /* * Work-around of a compilation error with ICC on invocations of the * rte_be_to_cpu_16() function. diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c new file mode 100644 index 0000000..87cbbcd --- /dev/null +++ b/app/test-pmd/util.c @@ -0,0 +1,143 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-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); +} + +void +dump_pkt_burst(struct fwd_stream *fs, struct rte_mbuf **pkts_burst, + uint16_t nb_pkts, int direction) +{ + 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; + + printf("port %u/queue %u: %s %u packets\n", + direction ? fs->rx_port : fs->tx_port, + direction ? (unsigned int) fs->rx_queue : + (unsigned int) fs->tx_queue, + direction ? "received" : "sent", + (unsigned int) nb_pkts); + for (i = 0; i < nb_pkts; i++) { + mb = pkts_burst[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); + printf(" - RSS hash=0x%x", (unsigned int) mb->hash.rss); + printf(" - RSS queue=0x%x", (unsigned int) 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_VLAN_STRIPPED) + printf(" - VLAN tci=0x%x", mb->vlan_tci); + if (ol_flags & PKT_RX_QINQ_STRIPPED) + printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x", + mb->vlan_tci, mb->vlan_tci_outer); + 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(" - 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_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 int) fs->rx_queue); + printf("\n"); + rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf)); + printf(" ol_flags: %s\n", buf); + } +} -- 2.7.4