@@ -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,
@@ -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
@@ -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 */
@@ -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;
}
@@ -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