From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Aman Singh <aman.deep.singh@intel.com>
Subject: [PATCH v10 7/8] test-pmd: add packet dissect format
Date: Sun, 27 Oct 2024 19:19:33 -0700 [thread overview]
Message-ID: <20241028022131.142609-8-stephen@networkplumber.org> (raw)
In-Reply-To: <20241028022131.142609-1-stephen@networkplumber.org>
Add ability to get decode packet in summary tshark style format.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test-pmd/cmdline.c | 6 ++--
app/test-pmd/config.c | 23 +++++++++----
app/test-pmd/testpmd.h | 1 +
app/test-pmd/util.c | 36 +++++++++++++++++++++
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 +-
5 files changed, 59 insertions(+), 10 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index fb73087880..0595da6749 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -318,7 +318,7 @@ static void cmd_help_long_parsed(void *parsed_result,
"set output (filename)\n"
" Set the packet debug log file\n\n"
- "set format (verbose|hex)\n"
+ "set format (dissect|hex|verbose)\n"
" Set the format of packet log\\n"
"set log global|(type) (level)\n"
@@ -4175,12 +4175,12 @@ static cmdline_parse_token_string_t cmd_set_format_set =
static cmdline_parse_token_string_t cmd_set_format_output =
TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, format, "format");
static cmdline_parse_token_string_t cmd_set_format_value =
- TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "verbose#hex");
+ TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "dissect#hex#verbose");
static cmdline_parse_inst_t cmd_set_format = {
.f = cmd_set_format_parsed,
.data = NULL,
- .help_str = "set format verbose|hex",
+ .help_str = "set format dissect|hex|verbose",
.tokens = {
(void *)&cmd_set_format_set,
(void *)&cmd_set_format_output,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 86c18a7dc1..410d5a60f2 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -6343,12 +6343,23 @@ set_verbose_level(uint16_t vb_level)
void
set_output_format(const char *mode)
{
- if (!strcmp(mode, "verbose"))
- output_format = OUTPUT_MODE_VERBOSE;
- else if (!strcmp(mode, "hex"))
- output_format = OUTPUT_MODE_HEX;
- else
- fprintf(stderr, "Unknown output format '%s'\n", mode);
+ static const char * const output_formats[] = {
+ [OUTPUT_MODE_VERBOSE] = "verbose",
+ [OUTPUT_MODE_HEX] = "hex",
+ [OUTPUT_MODE_DISSECT] = "dissect",
+ };
+
+ printf("Change output format from %s to %s\n",
+ output_formats[output_format], mode);
+
+ for (unsigned int i = 0; i < RTE_DIM(output_formats); i++) {
+ if (strcasecmp(mode, output_formats[i]) == 0) {
+ output_format = i;
+ return;
+ }
+ }
+
+ fprintf(stderr, "Unknown output format '%s'\n", mode);
}
void
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 6c21fb16f8..167bfeb00f 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -491,6 +491,7 @@ enum dcb_mode_enable
enum output_mode {
OUTPUT_MODE_VERBOSE = 0,
OUTPUT_MODE_HEX,
+ OUTPUT_MODE_DISSECT,
};
extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index 130821fddb..551e684e4c 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -8,6 +8,7 @@
#include <rte_bitops.h>
#include <rte_net.h>
#include <rte_mbuf.h>
+#include <rte_dissect.h>
#include <rte_ether.h>
#include <rte_vxlan.h>
#include <rte_ethdev.h>
@@ -311,6 +312,38 @@ dump_pkt_hex(FILE *outf, uint16_t port_id, uint16_t queue,
}
}
+/* Brief tshark style one line output which is
+ * number time_delta Source Destination Protocol len info
+ */
+static void
+dump_pkt_brief(FILE *outf, uint16_t port, uint16_t queue,
+ struct rte_mbuf *pkts[], uint16_t nb_pkts, int is_rx)
+{
+ static uint64_t start_cycles;
+ static RTE_ATOMIC(uint64_t) packet_count = 1;
+ uint64_t now, count;
+ double interval;
+
+ /* Compute time interval from the first packet received */
+ now = rte_rdtsc();
+ if (start_cycles == 0) {
+ start_cycles = now;
+ printf("Seq# Time Port:Que R Description\n");
+ }
+ interval = (double)(now - start_cycles) / (double)rte_get_tsc_hz();
+
+ /* Packet counter needs to be thread safe */
+ count = rte_atomic_fetch_add_explicit(&packet_count, nb_pkts, rte_memory_order_relaxed);
+
+ for (uint16_t i = 0; i < nb_pkts; i++) {
+ const struct rte_mbuf *mb = pkts[i];
+ char str[256];
+
+ rte_dissect_mbuf(str, sizeof(str), mb, 0);
+ fprintf(outf, "%6"PRIu64" %11.9f %4u:%-3u %c %s\n",
+ count + i, interval, port, queue, is_rx ? 'R' : 'T', str);
+ }
+}
static void
dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
@@ -332,6 +365,9 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
case OUTPUT_MODE_HEX:
dump_pkt_hex(outf, port_id, queue, pkts, nb_pkts, is_rx);
break;
+ case OUTPUT_MODE_DISSECT:
+ dump_pkt_brief(outf, port_id, queue, pkts, nb_pkts, is_rx);
+ break;
default:
return;
}
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 088dffd9fd..4a852297fb 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -696,12 +696,13 @@ set format
Chose the output format for packet debug log::
- testpmd> set format verbose|hex
+ testpmd> set format dissect|hex|verbose
Available formats are:
* ``verbose`` print the packet meta data information
* ``hex`` print the mbuf flags and data in hex
+* ``dissect`` print the packet in tshark summary format
set verbose
--
2.45.2
next prev parent reply other threads:[~2024-10-28 2:22 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 22:01 [PATCH] test-pmd: add more packet decode options (verbose) Stephen Hemminger
2024-03-13 21:49 ` Stephen Hemminger
2024-07-05 7:13 ` David Marchand
2024-07-23 2:44 ` [PATCH v2 0/3] Add packet dissector Stephen Hemminger
2024-07-23 2:44 ` [PATCH v2 1/3] net: add new " Stephen Hemminger
2024-07-23 2:44 ` [PATCH v2 2/3] test: add test for " Stephen Hemminger
2024-07-23 2:44 ` [PATCH v2 3/3] test-pmd: add more packet verbose decode options Stephen Hemminger
2024-07-23 20:33 ` [PATCH v3 0/3] add packet dissector function Stephen Hemminger
2024-07-23 20:33 ` [PATCH v3 1/3] net: add new packet dissector Stephen Hemminger
2024-07-23 20:33 ` [PATCH v3 2/3] test: add test for " Stephen Hemminger
2024-07-23 20:33 ` [PATCH v3 3/3] test-pmd: add more packet verbose decode options Stephen Hemminger
2024-07-24 18:46 ` [PATCH v4 0/3] Add packet dissector Stephen Hemminger
2024-07-24 18:46 ` [PATCH v4 1/3] net: add new " Stephen Hemminger
2024-07-24 18:46 ` [PATCH v4 2/3] test: add test for " Stephen Hemminger
2024-07-24 18:46 ` [PATCH v4 3/3] test-pmd: add more packet verbose decode options Stephen Hemminger
2024-08-01 19:04 ` [PATCH v5 0/4] Add network packet dissector Stephen Hemminger
2024-08-01 19:04 ` [PATCH v5 1/4] net: add more icmp types Stephen Hemminger
2024-08-01 19:04 ` [PATCH v5 2/4] net: add new packet dissector Stephen Hemminger
2024-08-01 19:04 ` [PATCH v5 3/4] test: add test for " Stephen Hemminger
2024-08-02 8:38 ` Bruce Richardson
2024-08-02 15:31 ` Stephen Hemminger
2024-08-02 18:06 ` Stephen Hemminger
2024-08-01 19:04 ` [PATCH v5 4/4] test-pmd: add more packet verbose decode options Stephen Hemminger
2024-08-02 18:07 ` [PATCH v6 0/4] Add network packet dissector Stephen Hemminger
2024-08-02 18:07 ` [PATCH v6 1/4] net: add more icmp types Stephen Hemminger
2024-08-02 18:07 ` [PATCH v6 2/4] net: add new packet dissector Stephen Hemminger
2024-08-02 18:07 ` [PATCH v6 3/4] test: add test for " Stephen Hemminger
2024-08-02 18:07 ` [PATCH v6 4/4] test-pmd: add more packet verbose decode options Stephen Hemminger
2024-08-02 19:56 ` [PATCH v7 0/4] Add network packet dissector Stephen Hemminger
2024-08-02 19:56 ` [PATCH v7 1/4] net: add more icmp types Stephen Hemminger
2024-08-02 19:56 ` [PATCH v7 2/4] net: add new packet dissector Stephen Hemminger
2024-08-02 19:56 ` [PATCH v7 3/4] test: add test for " Stephen Hemminger
2024-08-02 19:56 ` [PATCH v7 4/4] test-pmd: add more packet verbose decode options Stephen Hemminger
2024-08-20 13:42 ` Alex Chapman
2024-08-20 15:54 ` Stephen Hemminger
2024-08-22 9:04 ` Paul Szczepanek
2024-09-28 18:36 ` Stephen Hemminger
2024-09-17 3:27 ` [PATCH v8 0/7] Test-pmd packet decode enhancements Stephen Hemminger
2024-09-17 3:27 ` [PATCH v8 1/7] net: add more icmp types Stephen Hemminger
2024-09-17 3:27 ` [PATCH v8 2/7] net: add new packet dissector Stephen Hemminger
2024-09-17 3:28 ` [PATCH v8 3/7] test: add test for " Stephen Hemminger
2024-09-17 3:28 ` [PATCH v8 4/7] test-pmd: add option to redirect packet log Stephen Hemminger
2024-09-17 3:28 ` [PATCH v8 5/7] test-pmd: add hex decode Stephen Hemminger
2024-09-17 3:28 ` [PATCH v8 6/7] test-pmd: add packet dissect format Stephen Hemminger
2024-09-17 3:28 ` [PATCH v8 7/7] test-pmd: add a JSON packet output Stephen Hemminger
2024-09-28 16:18 ` [PATCH v9 0/8] test-pmd packet decoding enhancements Stephen Hemminger
2024-09-28 16:18 ` [PATCH v9 1/8] net: add more icmp types Stephen Hemminger
2024-09-28 16:18 ` [PATCH v9 2/8] net: add new packet dissector Stephen Hemminger
2024-09-28 16:18 ` [PATCH v9 3/8] mbuf: decode the hash and fdir info in rte_pktmbuf_dump Stephen Hemminger
2024-09-28 16:18 ` [PATCH v9 4/8] test: add test for packet dissector Stephen Hemminger
2024-09-28 16:18 ` [PATCH v9 5/8] test-pmd: add option to redirect packet log Stephen Hemminger
2024-09-28 16:18 ` [PATCH v9 6/8] test-pmd: add hex decode Stephen Hemminger
2024-09-28 16:18 ` [PATCH v9 7/8] test-pmd: add packet dissect format Stephen Hemminger
2024-09-28 16:18 ` [PATCH v9 8/8] test-pmd: add a JSON packet output Stephen Hemminger
2024-10-28 2:19 ` [PATCH v10 0/8] test-pmd packet decoding enhancements Stephen Hemminger
2024-10-28 2:19 ` [PATCH v10 1/8] net: add more icmp types Stephen Hemminger
2024-10-28 2:19 ` [PATCH v10 2/8] net: add new packet dissector Stephen Hemminger
2024-10-28 2:19 ` [PATCH v10 3/8] mbuf: decode the hash and fdir info in rte_pktmbuf_dump Stephen Hemminger
2024-10-28 2:19 ` [PATCH v10 4/8] test: add test for packet dissector Stephen Hemminger
2024-10-28 2:19 ` [PATCH v10 5/8] test-pmd: add option to redirect packet log Stephen Hemminger
2024-10-28 2:19 ` [PATCH v10 6/8] test-pmd: add hex decode Stephen Hemminger
2024-10-28 2:19 ` Stephen Hemminger [this message]
2024-10-28 2:19 ` [PATCH v10 8/8] test-pmd: add a JSON packet output Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241028022131.142609-8-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=aman.deep.singh@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).