From patchwork Sun Oct 7 07:38:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raslan Darawsheh X-Patchwork-Id: 46197 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D429C44C3; Sun, 7 Oct 2018 09:38:10 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00052.outbound.protection.outlook.com [40.107.0.52]) by dpdk.org (Postfix) with ESMTP id 1B7133798 for ; Sun, 7 Oct 2018 09:38:09 +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=69x7XOCZyT9G77orrMUkzjAb7ttcR/QFjpmlukGVNCw=; b=PhDZRGaAnmNYuyaR1c93YMFdfhdSa6rueA/miQPmvYmmzMLZGUvTa4XjXaWdmIabLBLrx/xKK/sT0boe0U7oG//up2xDVt99RfwEXeWa0AA/d6/PfTi0HJd5ZvYeiADRuqgXYk6RkxmJna1RN0bH5qU8897NotirCGsorbPzQP0= Received: from DB5PR05MB1254.eurprd05.prod.outlook.com (10.162.157.140) by DB5PR05MB1672.eurprd05.prod.outlook.com (10.165.6.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.27; Sun, 7 Oct 2018 07:38:07 +0000 Received: from DB5PR05MB1254.eurprd05.prod.outlook.com ([fe80::3516:b329:5c35:51a5]) by DB5PR05MB1254.eurprd05.prod.outlook.com ([fe80::3516:b329:5c35:51a5%2]) with mapi id 15.20.1185.029; Sun, 7 Oct 2018 07:38:07 +0000 From: Raslan Darawsheh To: "jingjing.wu@intel.com" CC: Thomas Monjalon , "dev@dpdk.org" , Shahaf Shuler , Raslan Darawsheh , "Xueming(Steven) Li" , Ori Kam , "jerin.jacob@caviumnetworks.com" , "david.marchand@6wind.com" , "bernard.iremonger@intel.com" Thread-Topic: [PATCH v4 1/3] app/testpmd: move dumping packets to a separate function Thread-Index: AQHUXhCvOnf6BEKfi0qTgHyiiuRxvA== Date: Sun, 7 Oct 2018 07:38:06 +0000 Message-ID: <1538897848-1693-1-git-send-email-rasland@mellanox.com> References: <1537793304-27883-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1537793304-27883-1-git-send-email-rasland@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HE1PR06CA0130.eurprd06.prod.outlook.com (2603:10a6:7:16::17) To DB5PR05MB1254.eurprd05.prod.outlook.com (2a01:111:e400:51cc::12) authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB5PR05MB1672; 6:EyRNlCtcICUuvNPmYZoGwqDaaU5mD/InffsTyG4GV2C5B0+fJ/neoG5TPDmhH2M+KV1L3rFBAj2w79hH4iQo8vUcqaxvc822LyLr5m9Ndcf5oE2X+3R5X1jZ+3qbOPrA8780ut5fOB7sE4DhrhLmzIC/TTInFJz4+0Z6uFjboS4jjKlC64NY5gnijj9OY2MrNChUnuq6PpSb+v6jcrb+zPwe7zVlx410TV+B/kwa1T6iwAIvFHv04zCUAsBdiMxNmgp5UPJRZF2MnT/cWpGZDGfi5fOvN+bwh37aVvvD8smMbNdsrGgTBdDXT5hyh5+QpQWxvz5rgKNOutSN0r4KiQffsKowCw9I84gHJ5icys+wIrWSmvdvh2gQjfR9pcyJq9YxVa+uUTbNYf8VRE2JwddDEIWFTh0G/qs8yZoz+diONr3NWwrGTeBk5M5Nt3NBujy3TxNEAxKXXKhtcDv1hg==; 5:DZHsb2UTQzocKRyVGc1dXVzX/eDXdJhvqkascq1otchGcp0QNTSEeYXfVdwA77zb9TsmEMI2/WA3KP9oLvnvcFFSC/bOxfh1A+W3cOpQZpcNA4XQWGP07zw2ilAE11gRVkhsMpaW9cYPQAqePClG4ydR4VmklQw+OcL2DzwSe58=; 7:Q/GaTf3urxIDmmtdAW3GiI1yqFIlMaUluMnGguKIoKTJXFrF7nIVNxHKcVuIkf7W3Kmw9A6xnoR2+BSIGCBoaDETtSmQ9r54GK8osD8rUJ9ilUe1Clt8DsJLPfSr81Uyd7wJ++slIJYn/bGQtmaeIEx224YXS2kCVPvMk+luoR3LzaXs9aRpRooD1JuVYrqvjQa3NPFnARuRPCUFNxvVPnVz9IOW4VjDzUgG73z3h3SsDvqEcsZ03+5uDEhBZDLs x-ms-office365-filtering-correlation-id: f2a617af-bdfb-4b3e-9f14-08d62c27d0df 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:DB5PR05MB1672; x-ms-traffictypediagnostic: DB5PR05MB1672: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr 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)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051); SRVR:DB5PR05MB1672; BCL:0; PCL:0; RULEID:; SRVR:DB5PR05MB1672; x-forefront-prvs: 0818724663 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(39860400002)(366004)(346002)(396003)(376002)(189003)(199004)(86362001)(575784001)(478600001)(71190400001)(71200400001)(97736004)(305945005)(6436002)(5660300001)(7736002)(36756003)(53936002)(316002)(4744004)(68736007)(2900100001)(14454004)(66066001)(14444005)(256004)(102836004)(26005)(8936002)(2351001)(8676002)(486006)(5250100002)(5640700003)(25786009)(446003)(2501003)(54906003)(81166006)(6512007)(81156014)(476003)(2906002)(186003)(6916009)(11346002)(6506007)(386003)(99286004)(2616005)(50226002)(6116002)(4326008)(76176011)(3846002)(52116002)(6486002)(106356001)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR05MB1672; H:DB5PR05MB1254.eurprd05.prod.outlook.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-antispam-message-info: IH3L5MbeRLgr6Db8hHvM0nsrvM5KU0ljRW0ZAq+zdY/WAyDMqO4ya1PfJ1OdU08R+WAET03FJAmNr0sNhDTW1wgoYFhrAJ34UoM3f7YH2PpCDLMyo7kseBRBUwG0j1NAT39EOrwsA0pUABCJHc2cahNQPzKjFwsvgjZIKaRDC6lARvPcS5WU2Dxik+nyM96uQKzu3CrHswoYlgST2wN06/cFib3jAyxMApAn1FlptHJjdit9bZ5XsJkfelk3bHtC1+IECclCscPta/fYmxsGD3d6RYkUZN83hC2grmzPOsJntAEJpqwT6uLFBNOwms9SipHoNoN59GWoRgFGbdTJMRT4SZKQX8ClNyCD9Eff7dw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2a617af-bdfb-4b3e-9f14-08d62c27d0df X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Oct 2018 07:38:06.8110 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR05MB1672 Subject: [dpdk-dev] [PATCH v4 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- changes in v3: - add util.c in the mason.build file - restore missing check for ol_flags & PKT_RX_RSS_HASH. - add local variables for rte_be_to_cpu to avoid long lines. changes in v4: - add missing l3 and l4 checks --- Signed-off-by: Raslan Darawsheh --- app/test-pmd/Makefile | 1 + app/test-pmd/meson.build | 3 +- app/test-pmd/rxonly.c | 134 +----------------------------------------- app/test-pmd/util.c | 150 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 132 deletions(-) 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/meson.build b/app/test-pmd/meson.build index a0b3be0..b96ab97 100644 --- a/app/test-pmd/meson.build +++ b/app/test-pmd/meson.build @@ -20,7 +20,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 a93d806..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_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(" - 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..e56b712 --- /dev/null +++ b/app/test-pmd/util.c @@ -0,0 +1,150 @@ +/* SPDX-License-Identifie.r: BSD-3-Clause + * Copyri.ght(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); +} + +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_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(" - 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); + } +} From patchwork Sun Oct 7 07:38:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raslan Darawsheh X-Patchwork-Id: 46198 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B9D384C8B; Sun, 7 Oct 2018 09:38:12 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50052.outbound.protection.outlook.com [40.107.5.52]) by dpdk.org (Postfix) with ESMTP id 6C4904C74 for ; Sun, 7 Oct 2018 09:38:11 +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=kuRO8ePpsb4ENwYCqQuVJbUzPpH8wSHCgST3jDuxwZU=; b=OVnHq3yF+Zc0/GsFjs+4iiiNlOsSVr5WSav+xX/bq8U7hYjgzPSBn20DpFcHbNiaZCS/W6eMYwoXv1DgIyNpCvLE2Kv8JPOmr7NYYSGlcTt2WUvPGMD5wiTZ2ewuFSJ4OcedsRmAJ+qwU5nflNm/6QyEJ6sAlnX4IJgvMo23HNI= Received: from DB5PR05MB1254.eurprd05.prod.outlook.com (10.162.157.140) by DB5PR05MB1672.eurprd05.prod.outlook.com (10.165.6.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.27; Sun, 7 Oct 2018 07:38:09 +0000 Received: from DB5PR05MB1254.eurprd05.prod.outlook.com ([fe80::3516:b329:5c35:51a5]) by DB5PR05MB1254.eurprd05.prod.outlook.com ([fe80::3516:b329:5c35:51a5%2]) with mapi id 15.20.1185.029; Sun, 7 Oct 2018 07:38:09 +0000 From: Raslan Darawsheh To: "jingjing.wu@intel.com" CC: Thomas Monjalon , "dev@dpdk.org" , Shahaf Shuler , Raslan Darawsheh , "Xueming(Steven) Li" , Ori Kam , "jerin.jacob@caviumnetworks.com" , "david.marchand@6wind.com" , "bernard.iremonger@intel.com" Thread-Topic: [PATCH v4 2/3] app/testpmd: add packet dump callback functions Thread-Index: AQHUXhCxpXLGA/tZEUGjKwmgQ65AJQ== Date: Sun, 7 Oct 2018 07:38:09 +0000 Message-ID: <1538897848-1693-2-git-send-email-rasland@mellanox.com> References: <1537793304-27883-1-git-send-email-rasland@mellanox.com> <1538897848-1693-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1538897848-1693-1-git-send-email-rasland@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HE1PR06CA0130.eurprd06.prod.outlook.com (2603:10a6:7:16::17) To DB5PR05MB1254.eurprd05.prod.outlook.com (2a01:111:e400:51cc::12) authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB5PR05MB1672; 6:YzLARHCnDCntiOrzbtCEbzGsWjZGdh3/LqvOFF5rPj3KHT91mL+Osy8NJTX0VrE3EnM43GX4JawaUI0dZrdmYGTL2FUZh/Qtq3FRGmtxQbOf4a/GafHXcdD26YommXThIVWSY3dYWcTNpQNqvxwF+OeEUMK3+5JC6fgdkt1tgDoZJKlTI/PytLrWN05OFh2zqy9OgEXVxeWHrHWkPk16UXbT4kjW7cMhnQwCH9n/4jq7rKU4hPt9SzF5dEnhgWBuRskT8mj2y9pjYThE04Y/2bFAlCXZV//4LT9wFp2G95/zCz5U2hexq4odt03D+0HC9ievj8+7gLDvFGnZGKhy36NYGKuXiH/chM47hEMdd4tSCUwe3gxS/MxjcvRLcdqZ6SMYzY3jw1D6v88rIIWrm63xOLo2ldYJepmypnd+tyQfIIYD25Q3JJQFRM0CRxBEtoVV+1/w9u43hInVROSoAA==; 5:ahsIyCPMd2DIR29hhI/S/CcoPHZ7MwU/dsxNBm9tV4vCF+twI2IcTBc7vJmErt1HAcuYbVBwl5/f/IeJm4PCuU5vQgF99l5rL5q3O4MHzxvU/7v2ynm4Wc76o75qLlqjnx0lYMSG59B38NomyZi2l24slT80II6tSKZ+R5jrFFc=; 7:UaJz077/Jma1PdjFPQvUAFwvGGP+sn10XulIx9oQ+mYKoekkAhRVAAFsu7KE8ec5BQY7AP5hpOKnxk7icThqnpbWq9pmP8dtHLk3RsOW/vBoLyrCpJssZvSWOBuNJQFiUfgiJZzKPhvUHsPCimXH7KfaMpFqMn7tiDL3apfB/H3+MrYFeeRUKOp2LP8SL8l0uYPxdJfA+Va41penIjXLFeuGrRB1lmfvcoSsas3RELQAEWRFyz2pNSxfERcCEfbc x-ms-office365-filtering-correlation-id: d91f4aac-cc6f-46ea-7ea2-08d62c27d3b1 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:DB5PR05MB1672; x-ms-traffictypediagnostic: DB5PR05MB1672: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr 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)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051); SRVR:DB5PR05MB1672; BCL:0; PCL:0; RULEID:; SRVR:DB5PR05MB1672; x-forefront-prvs: 0818724663 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(39860400002)(366004)(346002)(396003)(376002)(189003)(199004)(86362001)(575784001)(478600001)(71190400001)(71200400001)(97736004)(305945005)(6436002)(5660300001)(7736002)(36756003)(53936002)(316002)(68736007)(2900100001)(14454004)(66066001)(256004)(102836004)(26005)(8936002)(2351001)(8676002)(486006)(5250100002)(5640700003)(25786009)(446003)(2501003)(54906003)(81166006)(6512007)(81156014)(476003)(2906002)(186003)(6916009)(11346002)(6506007)(386003)(99286004)(2616005)(50226002)(6116002)(4326008)(76176011)(3846002)(52116002)(6486002)(106356001)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR05MB1672; H:DB5PR05MB1254.eurprd05.prod.outlook.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-antispam-message-info: kTPvvs08jv5E5EmPfY11xqwmHDxjwsIQci/R09mcflZYNXWCXxG3KE66TBLOUVeL5bjaEY6RJnZ5DgyKXxMf6b4ymWE+2BtXN0YvoSA64mI9tsDZy2Stvv5J1w5BsfGEwodHjJ4OnsECmYywWBEXNyYm+jOHuiqKJTCdgCyjyJ6SST8UtnnfYc6PJ28aEyMMPoyLYnsJ+LDUdSmNCsywYsA2K64+1sV6AAd3MjTwsIfZoCANFL5gRBaVJoOQNYN+y8rik+8QHyslZt/c0yRxW7JwX+Ou4Bpoe57lb18c94cV9BGiE9wqHLN5V6oxo1gS1L2v8Uvh2kMD2xybXvB87COH9IkAxwcW0IRAjMPvLww= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: d91f4aac-cc6f-46ea-7ea2-08d62c27d3b1 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Oct 2018 07:38:09.1429 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR05MB1672 Subject: [dpdk-dev] [PATCH v4 2/3] app/testpmd: add packet dump callback functions 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" add new rx/tx callback functions to be used for dumping the packets. Signed-off-by: Raslan Darawsheh Acked-by: Bernard Iremonger --- app/test-pmd/config.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 15 +++++++++++ app/test-pmd/util.c | 17 +++++++++++++ 3 files changed, 99 insertions(+) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a0f9349..fb45fea 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2896,6 +2896,73 @@ set_pkt_forwarding_mode(const char *fwd_mode_name) } void +add_rx_dump_callbacks(portid_t portid) +{ + struct rte_eth_dev_info dev_info; + uint16_t queue; + + if (port_id_is_invalid(portid, ENABLED_WARN)) + return; + + rte_eth_dev_info_get(portid, &dev_info); + for (queue = 0; queue < dev_info.nb_rx_queues; queue++) + if (!ports[portid].rx_dump_cb[queue]) + ports[portid].rx_dump_cb[queue] = + rte_eth_add_rx_callback(portid, queue, + dump_rx_pkts, NULL); +} + +void +add_tx_dump_callbacks(portid_t portid) +{ + struct rte_eth_dev_info dev_info; + uint16_t queue; + + if (port_id_is_invalid(portid, ENABLED_WARN)) + return; + rte_eth_dev_info_get(portid, &dev_info); + for (queue = 0; queue < dev_info.nb_tx_queues; queue++) + if (!ports[portid].tx_dump_cb[queue]) + ports[portid].tx_dump_cb[queue] = + rte_eth_add_tx_callback(portid, queue, + dump_tx_pkts, NULL); +} + +void +remove_rx_dump_callbacks(portid_t portid) +{ + struct rte_eth_dev_info dev_info; + uint16_t queue; + + if (port_id_is_invalid(portid, ENABLED_WARN)) + return; + rte_eth_dev_info_get(portid, &dev_info); + for (queue = 0; queue < dev_info.nb_rx_queues; queue++) + if (ports[portid].rx_dump_cb[queue]) { + rte_eth_remove_rx_callback(portid, queue, + ports[portid].rx_dump_cb[queue]); + ports[portid].rx_dump_cb[queue] = NULL; + } +} + +void +remove_tx_dump_callbacks(portid_t portid) +{ + struct rte_eth_dev_info dev_info; + uint16_t queue; + + if (port_id_is_invalid(portid, ENABLED_WARN)) + return; + rte_eth_dev_info_get(portid, &dev_info); + for (queue = 0; queue < dev_info.nb_tx_queues; queue++) + if (ports[portid].tx_dump_cb[queue]) { + rte_eth_remove_tx_callback(portid, queue, + ports[portid].tx_dump_cb[queue]); + ports[portid].tx_dump_cb[queue] = NULL; + } +} + +void set_verbose_level(uint16_t vb_level) { printf("Change verbose level from %u to %u\n", diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index a1f6614..c0d7656 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -180,6 +180,8 @@ struct rte_port { uint32_t mc_addr_nb; /**< nb. of addr. in mc_addr_pool */ uint8_t slave_flag; /**< bonding slave port */ struct port_flow *flow_list; /**< Associated flows. */ + const struct rte_eth_rxtx_callback *rx_dump_cb[MAX_QUEUE_ID+1]; + const struct rte_eth_rxtx_callback *tx_dump_cb[MAX_QUEUE_ID+1]; #ifdef SOFTNIC struct softnic_port softport; /**< softnic params */ #endif @@ -743,6 +745,19 @@ int check_nb_rxq(queueid_t rxq); queueid_t get_allowed_max_nb_txq(portid_t *pid); int check_nb_txq(queueid_t txq); + +uint16_t dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], + uint16_t nb_pkts, __rte_unused uint16_t max_pkts, + __rte_unused void *user_param); + +uint16_t dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], + uint16_t nb_pkts, __rte_unused void *user_param); + +void add_rx_dump_callbacks(portid_t portid); +void remove_rx_dump_callbacks(portid_t portid); +void add_tx_dump_callbacks(portid_t portid); +void remove_tx_dump_callbacks(portid_t portid); + /* * 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 index e56b712..6fa2284 100644 --- a/app/test-pmd/util.c +++ b/app/test-pmd/util.c @@ -148,3 +148,20 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], printf(" ol_flags: %s\n", buf); } } + +uint16_t +dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], + uint16_t nb_pkts, __rte_unused uint16_t max_pkts, + __rte_unused void *user_param) +{ + dump_pkt_burst(port_id, queue, pkts, nb_pkts, 1); + return nb_pkts; +} + +uint16_t +dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], + uint16_t nb_pkts, __rte_unused void *user_param) +{ + dump_pkt_burst(port_id, queue, pkts, nb_pkts, 0); + return nb_pkts; +} From patchwork Sun Oct 7 07:38:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raslan Darawsheh X-Patchwork-Id: 46199 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 46D2B4C8E; Sun, 7 Oct 2018 09:38:16 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00043.outbound.protection.outlook.com [40.107.0.43]) by dpdk.org (Postfix) with ESMTP id 3A1164C8E for ; Sun, 7 Oct 2018 09:38:14 +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=MySaOVrPXJv1fdlMr12YDLN59jvMh5036pUt9NnkhpY=; b=pahI3tubGELBCLEWC9FRmQRs9sfSSDrgW3UEQDlPl79f1NaR/tahJy/6AoSDN50YmN800g96HJNi/zZcelENFLZz7r66MtAFIrMJBuj8NAd/YnqprsCJ0+uKRVG55cps2B0yQaMjyNOvRQe957BkXtKWFKHLU42CriDqs9sxhhA= Received: from DB5PR05MB1254.eurprd05.prod.outlook.com (10.162.157.140) by DB5PR05MB1672.eurprd05.prod.outlook.com (10.165.6.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.27; Sun, 7 Oct 2018 07:38:11 +0000 Received: from DB5PR05MB1254.eurprd05.prod.outlook.com ([fe80::3516:b329:5c35:51a5]) by DB5PR05MB1254.eurprd05.prod.outlook.com ([fe80::3516:b329:5c35:51a5%2]) with mapi id 15.20.1185.029; Sun, 7 Oct 2018 07:38:11 +0000 From: Raslan Darawsheh To: "jingjing.wu@intel.com" CC: Thomas Monjalon , "dev@dpdk.org" , Shahaf Shuler , Raslan Darawsheh , "Xueming(Steven) Li" , Ori Kam , "jerin.jacob@caviumnetworks.com" , "david.marchand@6wind.com" , "bernard.iremonger@intel.com" Thread-Topic: [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level Thread-Index: AQHUXhCyni36MbSRZkisi9xJ6/r4vQ== Date: Sun, 7 Oct 2018 07:38:11 +0000 Message-ID: <1538897848-1693-3-git-send-email-rasland@mellanox.com> References: <1537793304-27883-1-git-send-email-rasland@mellanox.com> <1538897848-1693-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1538897848-1693-1-git-send-email-rasland@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HE1PR06CA0130.eurprd06.prod.outlook.com (2603:10a6:7:16::17) To DB5PR05MB1254.eurprd05.prod.outlook.com (2a01:111:e400:51cc::12) authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB5PR05MB1672; 6:DlXycTBF1YoY8L66EV8tH7wAM/I7z6FjhU/i3hygEGA+Yh8WS8/bPq4gskquAiz5pgEk8MByDIjKeqGv5Jex3dBREUkUBvaU8tvpfDfvSyfs4yGFUALx2DD6IgM7Os5znUkNzxVTojucPlPnrRxY4dZgyjNwXn6J7U3weAxivmzxTDwKDtwQvogP9GBdp541vfUUkSal0gKku3/cYSOxXeZBK84Ym/eJ7uSNDdOevPGVbfwxzSlIAM85HgvD3AhRTuZ112eRIuENPiZuLRwqjbIT8Pd0L4PrPmzJpHEplCAUOIGat9G7PQxwYNVrhyCuUpp/6sLB1gx4R8V7Nymi1rbS0x3RjUowuryCEr9YXnOoKbSHsSAcdQszxYONdkaMYFHrEnY4HmMK51+UbLqgc4sb5qlaJ1BQNRfioKlr18mwMhg+saE0SJ7cVxYqhCIxpySLBtBoLbRJFPAlSsa/Lg==; 5:UzDzu8H2mSsozbR/qj/5XLUfJUfwQ6j5ttpG8wtDhHptf/L95V2C9sxGSr5RfAM49E9hAhEhzsZYaqsxmjIQL3WFK+QwrBFm4MVPSX2odneAt4662eWLWCcGh6pZ+99CBD1h2Vx2djBKot3XG0P0Uqj3sgDd7cmOFbxDDaXZ5mE=; 7:fmMumImbIEB0esJozsHGCPxKfbTsiQXAEoy2Xd41xKZw8bA8j2VQxLvdRk/GtFDUYXPInKsadK2Qls2kFFUohADHAAAaB6dc7dVUJITA7ro9fxr54L1UyJQ44JcMgI9lY/E1209szeb6LGiqfR9Ht6Ef7UlQRVVJ3yEnw/+djA+kpubnfunEEIvY2eJMd6n3TH9TxlSnsN/dYIuaycrCMsrkqHh5P1hEQ38XF4DLQd6icvX77Cs65LBIRv2o3UXP x-ms-office365-filtering-correlation-id: e96c89bb-f067-45b7-77d4-08d62c27d515 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:DB5PR05MB1672; x-ms-traffictypediagnostic: DB5PR05MB1672: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr 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)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051); SRVR:DB5PR05MB1672; BCL:0; PCL:0; RULEID:; SRVR:DB5PR05MB1672; x-forefront-prvs: 0818724663 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(39860400002)(366004)(346002)(396003)(376002)(189003)(199004)(86362001)(575784001)(478600001)(71190400001)(71200400001)(97736004)(305945005)(6436002)(5660300001)(7736002)(36756003)(53936002)(316002)(68736007)(2900100001)(14454004)(66066001)(256004)(102836004)(26005)(8936002)(2351001)(8676002)(486006)(5250100002)(5640700003)(25786009)(446003)(2501003)(54906003)(81166006)(6512007)(81156014)(476003)(2906002)(186003)(6916009)(11346002)(6506007)(386003)(99286004)(2616005)(50226002)(6116002)(4326008)(76176011)(3846002)(52116002)(6486002)(106356001)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR05MB1672; H:DB5PR05MB1254.eurprd05.prod.outlook.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-antispam-message-info: 1CFNJjoQmY/QDNdn+flJUOsjq90Rrn68lAp0nLv39bE5td6Wc5mo5rK8CYBs/4OGDHN2Fii633h+Z59LaQFPGDzhMFIpUqt3lsu/KC/acNdrRReGHv4bIdKw9+P0QN/n8f4g4b+oLh2fdoBveqlcVsf2Z0AsDZbm4e0hu8mZigEJFEuthWRTs94X8NLQKOZOthgqURWVFDs5cUryj2nBDsMwTO+NWybRoR2X9OlE3RNSkif2brWMzqKlivit4DtDn/mpJ8GZhdtrw/KbkhUR6FHb3aQwhwob2jlJH+LAGmUuvkVWO/04Jt6ZEffDLIiWyuvm9A3fCrErnDlDyoxi1imVzLdf1+0+H90wLjspwsE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: e96c89bb-f067-45b7-77d4-08d62c27d515 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Oct 2018 07:38:11.4858 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR05MB1672 Subject: [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" when changing verbosity level it will configure rx/tx callbacks to dump packets based on the verbosity value as following: 1- dump only received packets: testpmd> set verbose 1 2- dump only sent packets: testpmd> set verbose 2 3- dump sent and received packets: testpmd> set verbose (any number > 2) 4- disable dump testpmd> set verbose 0 Signed-off-by: Raslan Darawsheh Acked-by: Bernard Iremonger --- app/test-pmd/config.c | 25 +++++++++++++++++++++++++ app/test-pmd/testpmd.c | 4 ++-- app/test-pmd/testpmd.h | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index fb45fea..f402e04 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -50,6 +50,7 @@ #endif #include #include +#include #include "testpmd.h" @@ -2963,11 +2964,35 @@ remove_tx_dump_callbacks(portid_t portid) } void +configure_rxtx_dump_callbacks(uint16_t verbose) +{ + portid_t portid; + +#ifndef RTE_ETHDEV_RXTX_CALLBACKS + TESTPMD_LOG(ERR, "setting rxtx callbacks is not enabled\n"); + return; +#endif + + RTE_ETH_FOREACH_DEV(portid) + { + if (verbose == 1 || verbose > 2) + add_rx_dump_callbacks(portid); + else + remove_rx_dump_callbacks(portid); + if (verbose >= 2) + add_tx_dump_callbacks(portid); + else + remove_tx_dump_callbacks(portid); + } +} + +void set_verbose_level(uint16_t vb_level) { printf("Change verbose level from %u to %u\n", (unsigned int) verbose_level, (unsigned int) vb_level); verbose_level = vb_level; + configure_rxtx_dump_callbacks(verbose_level); } void diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 571ecb4..538723c 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1665,7 +1665,7 @@ start_port(portid_t pid) return -1; } } - + configure_rxtx_dump_callbacks(0); printf("Configuring Port %d (socket %u)\n", pi, port->socket_id); /* configure port */ @@ -1764,7 +1764,7 @@ start_port(portid_t pid) return -1; } } - + configure_rxtx_dump_callbacks(verbose_level); /* start port */ if (rte_eth_dev_start(pi) < 0) { printf("Fail to start port %d\n", pi); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index c0d7656..e68710d 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -757,6 +757,7 @@ void add_rx_dump_callbacks(portid_t portid); void remove_rx_dump_callbacks(portid_t portid); void add_tx_dump_callbacks(portid_t portid); void remove_tx_dump_callbacks(portid_t portid); +void configure_rxtx_dump_callbacks(uint16_t verbose); /* * Work-around of a compilation error with ICC on invocations of the