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 11E6F4568C; Tue, 23 Jul 2024 04:46:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D304C40E2D; Tue, 23 Jul 2024 04:45:54 +0200 (CEST) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mails.dpdk.org (Postfix) with ESMTP id EC9E540E18 for ; Tue, 23 Jul 2024 04:45:49 +0200 (CEST) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-70d24d0a8d4so1030424b3a.0 for ; Mon, 22 Jul 2024 19:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1721702749; x=1722307549; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JBOMz4nzLz4LyTiYaCD4cXSF+LDtqV4ypha6V7cDd/o=; b=C++kGkOdVkmUV9b7wjDhHS7K+2tfpGVArk4CzCQt8utZbU3tnemRflGyB8zeWel14g HDdxt4BsWd9iuo9SEMaNgPr4o6VRWvTuVlLIppwZIcl6n0Jz1AsBQ4qugx11Un1MeUNF ZkV/WGW0U9jbrAjLqs3Q1+nF8UenDP5lfgqMlxuw89cV1CF2Mxu5mj2veCU9dHlu9WbT xSYrrckKMTfarpKp+75X29SnX//tBVdkvbPB+cUh0Be0TUFwSJzobdMQswDot40QX1+B fQ9nboa7oSCkzKzysuTvjIt+bZ6m12HuhOxTG4pdbsoq/yrgjcq+d6n8vLHe/XgLc1rM 8Png== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721702749; x=1722307549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JBOMz4nzLz4LyTiYaCD4cXSF+LDtqV4ypha6V7cDd/o=; b=gHH0nXDBwqeEtw4bRD4ey2lyFFCLBZbTRpolSZej0YujkKOU7jMa4gD8y/XUbRex9O YRewFqaSb7sxeuFI2ZMJ2WGqf45FRHA9O3QlT4HI6aDJKd3NLLZb7OK1NTyPIEpEzI1z weqGt/6Ur443ZVRKrxDLh4F119fPk5ezwRTszSB05HAFsb+GFq1UJSGiRNpY4XEJp6Ye LohfJFvgrzUOukQpfATRMfhwgp4wHHC7TPS4EZCDNgH4ECFXqzftttKBnYyrRr37PEI3 xOOo1VSWtdc0WNUBR6eYtFcf13Od3wjea1lWnf/jH6kaXxTSSP47cm7n1z1gtj0slRpF vLcQ== X-Gm-Message-State: AOJu0YwVawKc7JaAjhXaYJfCHVLE8fpmvXygboPAnhzSvd1oYQOkfQGz +djQchRmrMKZ8zDi9az890XwwC1hQYJ83+grB53+0F8qRarpxQBV7ruDyreEfQPraWuBMlCM5/8 LnNA= X-Google-Smtp-Source: AGHT+IG4VnH3CC17oDAJOsx5c1Wif6IZjA34XWQ4YMvo89yb2iDBNYgIxtr9k3+0MM4xAL1izFJvSw== X-Received: by 2002:a05:6a20:3d87:b0:1c2:8d72:67ce with SMTP id adf61e73a8af0-1c4228963c3mr9230696637.15.1721702749017; Mon, 22 Jul 2024 19:45:49 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ccf808f05bsm7838924a91.40.2024.07.22.19.45.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 19:45:48 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Ori Kam , Aman Singh Subject: [PATCH v2 3/3] test-pmd: add more packet verbose decode options Date: Mon, 22 Jul 2024 19:44:12 -0700 Message-ID: <20240723024537.980016-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240723024537.980016-1-stephen@networkplumber.org> References: <20240312220129.70667-1-stephen@networkplumber.org> <20240723024537.980016-1-stephen@networkplumber.org> 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 The existing verbose levels 1..3 provide a messy multi-line output per packet. I found this unhelpful when diagnosing many types of problems like packet flow. This patch keeps the previous levels and adds two new levels: 4: one line per packet is printed in a format resembling tshark output. With addresses and protocol info. 5: dump packet in hex. Useful if the driver is messing up the data. Signed-off-by: Stephen Hemminger --- app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 ++++++---- app/test-pmd/testpmd.h | 11 ++++ app/test-pmd/util.c | 71 +++++++++++++++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- 5 files changed, 105 insertions(+), 18 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index a76b44bf39..f553828755 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -14076,7 +14076,8 @@ cmd_set_raw_parsed(const struct buffer *in) upper_layer = proto; } } - if (verbose_level & 0x1) + + if (verbose_level > 0) printf("total data size is %zu\n", (*total_size)); RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA); memmove(data, (data_tail - (*total_size)), *total_size); diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 66c3a68c1d..5f01e70875 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -6246,26 +6246,37 @@ configure_rxtx_dump_callbacks(uint16_t verbose) return; #endif - RTE_ETH_FOREACH_DEV(portid) - { - if (verbose == 1 || verbose > 2) + RTE_ETH_FOREACH_DEV(portid) { + switch (verbose) { + case VERBOSE_OFF: + remove_rx_dump_callbacks(portid); + remove_tx_dump_callbacks(portid); + break; + case VERBOSE_RX: add_rx_dump_callbacks(portid); - else + remove_tx_dump_callbacks(portid); + break; + case VERBOSE_TX: + add_tx_dump_callbacks(portid); remove_rx_dump_callbacks(portid); - if (verbose >= 2) + break; + default: + add_rx_dump_callbacks(portid); 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); + if (vb_level < VERBOSE_MAX) { + printf("Change verbose level from %u to %u\n", verbose_level, vb_level); + verbose_level = vb_level; + configure_rxtx_dump_callbacks(verbose_level); + } else { + fprintf(stderr, "Verbose level %u is out of range\n", vb_level); + } } void diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 9facd7f281..3d7a2b6dac 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -489,6 +489,17 @@ enum dcb_mode_enable extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */ +enum verbose_mode { + VERBOSE_OFF = 0, + VERBOSE_RX, + VERBOSE_TX, + VERBOSE_BOTH, + VERBOSE_DISSECT, + VERBOSE_HEX, + VERBOSE_MAX +}; + + /* globals used for configuration */ extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */ extern uint8_t record_burst_stats; /**< Enables display of RX and TX bursts */ diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c index bf9b639d95..209c46b10d 100644 --- a/app/test-pmd/util.c +++ b/app/test-pmd/util.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -16,6 +17,7 @@ #include "testpmd.h" #define MAX_STRING_LEN 8192 +#define MAX_DUMP_LEN 1024 #define MKDUMPSTR(buf, buf_size, cur_len, ...) \ do { \ @@ -67,9 +69,10 @@ get_timestamp(const struct rte_mbuf *mbuf) timestamp_dynfield_offset, rte_mbuf_timestamp_t *); } -static inline void -dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], - uint16_t nb_pkts, int is_rx) +/* More verbose older style packet decode */ +static void +dump_pkt_verbose(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], + uint16_t nb_pkts, int is_rx) { struct rte_mbuf *mb; const struct rte_ether_hdr *eth_hdr; @@ -90,8 +93,6 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], size_t cur_len = 0; uint64_t restore_info_dynflag; - if (!nb_pkts) - return; restore_info_dynflag = rte_flow_restore_info_dynflag(); MKDUMPSTR(print_buf, buf_size, cur_len, "port %u/queue %u: %s %u packets\n", port_id, queue, @@ -299,6 +300,66 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], } } +/* Brief tshark style one line output which is + * number time_delta Source Destination Protocol len info + */ +static void +dump_pkt_brief(uint16_t queue, struct rte_mbuf *pkts[], uint16_t nb_pkts) +{ + static uint64_t start_cycles; + static uint64_t packet_count; + uint64_t now; + uint64_t count; + double interval; + uint16_t i; + + now = rte_rdtsc(); + if (start_cycles == 0) + start_cycles = now; + interval = (double)(now - start_cycles) / (double)rte_get_tsc_hz(); + + count = __atomic_fetch_add(&packet_count, nb_pkts, __ATOMIC_RELAXED); + + for (i = 0; i < nb_pkts; i++) { + const struct rte_mbuf *mb = pkts[i]; + + printf("%6"PRIu64" %11.9f %4u:%-3u ", count + i, interval, mb->port, queue); + rte_dissect_mbuf(stdout, mb, 0); + } +} + +/* Hex dump of packet data */ +static void +dump_pkt_hex(struct rte_mbuf *pkts[], uint16_t nb_pkts) +{ + uint16_t i; + + for (i = 0; i < nb_pkts; i++) + rte_pktmbuf_dump(stdout, pkts[i], MAX_DUMP_LEN); + +} + +static uint16_t +dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], + uint16_t nb_pkts, int is_rx) +{ + if (unlikely(nb_pkts == 0)) + return 0; + + switch (verbose_level) { + case VERBOSE_RX ... VERBOSE_BOTH: + dump_pkt_verbose(port_id, queue, pkts, nb_pkts, is_rx); + break; + case VERBOSE_DISSECT: + dump_pkt_brief(queue, pkts, nb_pkts); + break; + case VERBOSE_HEX: + dump_pkt_hex(pkts, nb_pkts); + } + fflush(stdout); + return nb_pkts; +} + 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, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index c19b4f8958..688806754a 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -676,7 +676,10 @@ Available levels are as following: * ``0`` silent except for error. * ``1`` fully verbose except for Tx packets. * ``2`` fully verbose except for Rx packets. -* ``> 2`` fully verbose. +* ``3`` fully verbose except for Tx and Rx packets. +* ``4`` dissected protocol information for Tx and Rx packets. +* ``5`` hex dump of packets + set log ~~~~~~~ -- 2.43.0