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 2753145A50; Sat, 28 Sep 2024 18:21:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C4DA40651; Sat, 28 Sep 2024 18:20:57 +0200 (CEST) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id 8A8CB402BA for ; Sat, 28 Sep 2024 18:20:52 +0200 (CEST) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-20b01da232aso22417865ad.1 for ; Sat, 28 Sep 2024 09:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727540452; x=1728145252; 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=7niHkHIUl5tB1k6DhuO9vAD6gquYuN8VM44IlDTCpPo=; b=1361GNkdqpzMekipYcWptgkO5q/Y4/zM0yxx2JwUCcdOnk7oi8f7zCAClSJt07JzSm TqOsUrGiC0ajC890iF2rNU3BNhbEEh88dOjlRKAcMDh0WXJrRfZZir7DTDimbheHndiZ SIzZdtYSuoePy8JyThg/SaoTKcBS9+HNxksq0HXphFhA0Nk6IyG7NAg+Zek3hB/ecEW3 XMJ/5409CTLcJQCe3BQ7A2I7CAjcOxxhMwFuzUT1Akn3d8RpjaPHkW75b98gSMPfWggO +oEjQpOuo7IfFLxoJYfvnFPgEkt3H3NguXYeNe43DoHN1MXwuhMTaEb9leNql10shm6k GZqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727540452; x=1728145252; 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=7niHkHIUl5tB1k6DhuO9vAD6gquYuN8VM44IlDTCpPo=; b=TsjasmUxKJ7+09KXfeXXYZlfhI7NrbB7s/jyegwHZtRxTzIqq9AErQxBHMa+g7zZtU IaVR273bK7Nt/UYBMFRo4wzvA+AsI7jt287EkN4SFb3Jaej5SCGA//0bNkZldxSHm9wo QcAfw30/pfMdL+aqf/ye7B3TCwjJdCWZdl3/5VLfM8nDOocyfDbcwZyqAFZx/ITeD33H Imh7D2snh2rnf6otrlOj1IsA9P3TFbzpp83x2/tXyX3R/E1R9QuZpx3D1d3MN6zgQUwG NsuXom/1O6W04xC4Seaqr6XmokOHqfSmjSOIxGzsWNHPlRy6EOr+orGPnJib6yHMGH8E hK4g== X-Gm-Message-State: AOJu0YygSJnMZ6am1k/Qz1d1m1prXrpn+CdIftiodK+AeU4wLKEtl1Hv O6G9wxFSp/Km2FGMF/ypOlbZ6aS0ZdKROsf7jyjB1e6VBDX3f3CEo4dT2GzYqkV5T/qkBRsnCeZ 9 X-Google-Smtp-Source: AGHT+IHB9XrBL9ojNrLSo0A/OMLiHZOT57WsxV1IctrQcGedccKR8ZYTuMPeH2BPWUKd6br+PknXlg== X-Received: by 2002:a17:903:2a84:b0:205:8a8b:bd2a with SMTP id d9443c01a7336-20b19cadb22mr136782935ad.22.1727540451635; Sat, 28 Sep 2024 09:20:51 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db2b9407sm2969107a12.23.2024.09.28.09.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:20:51 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Aman Singh Subject: [PATCH v9 7/8] test-pmd: add packet dissect format Date: Sat, 28 Sep 2024 09:18:37 -0700 Message-ID: <20240928162035.849326-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240928162035.849326-1-stephen@networkplumber.org> References: <20240312220129.70667-1-stephen@networkplumber.org> <20240928162035.849326-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 Add ability to get decode packet in summary tshark style format. Signed-off-by: Stephen Hemminger --- 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 37cce4868e..72be5a0c06 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -305,7 +305,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" @@ -3918,12 +3918,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 f30bdfc7ff..36b7aa1307 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -6271,12 +6271,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 94e8f59ef0..66b0317b61 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 #include #include +#include #include #include #include @@ -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 9406af3225..705b3dc3d5 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -677,12 +677,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