summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vnet/pg/cli.c101
-rw-r--r--src/vnet/pg/edit.c2
-rw-r--r--src/vnet/pg/pg.h1
-rw-r--r--src/vnet/pg/stream.c25
4 files changed, 97 insertions, 32 deletions
diff --git a/src/vnet/pg/cli.c b/src/vnet/pg/cli.c
index a09107c50c5..bca05515379 100644
--- a/src/vnet/pg/cli.c
+++ b/src/vnet/pg/cli.c
@@ -42,9 +42,9 @@
#include <vnet/vnet.h>
#include <vnet/pg/pg.h>
-#ifdef CLIB_UNIX
+#include <strings.h>
#include <vppinfra/pcap.h>
-#endif
+
/* Root of all packet generator cli commands. */
/* *INDENT-OFF* */
@@ -146,39 +146,65 @@ VLIB_CLI_COMMAND (disable_streams_cli, static) = {
/* *INDENT-ON* */
static u8 *
+format_pg_edit_group (u8 * s, va_list * va)
+{
+ pg_edit_group_t *g = va_arg (*va, pg_edit_group_t *);
+
+ s =
+ format (s, "hdr-size %d, offset %d, ", g->n_packet_bytes,
+ g->start_byte_offset);
+ if (g->edit_function)
+ {
+ u8 *function_name;
+ u8 *junk_after_name;
+ function_name = format (0, "%U%c", format_clib_elf_symbol_with_address,
+ g->edit_function, 0);
+ junk_after_name = function_name;
+ while (*junk_after_name && *junk_after_name != ' ')
+ junk_after_name++;
+ *junk_after_name = 0;
+ s = format (s, "edit-funtion %s, ", function_name);
+ vec_free (function_name);
+ }
+
+ return s;
+}
+
+static u8 *
format_pg_stream (u8 * s, va_list * va)
{
pg_stream_t *t = va_arg (*va, pg_stream_t *);
- u8 *v;
+ int verbose = va_arg (*va, int);
if (!t)
- return format (s, "%=16s%=12s%=16s%s",
+ return format (s, "%-16s%=12s%=16s%s",
"Name", "Enabled", "Count", "Parameters");
- s = format (s, "%-16v%=12s%16Ld",
+ s = format (s, "%-16v%=12s%=16Ld",
t->name,
pg_stream_is_enabled (t) ? "Yes" : "No",
t->n_packets_generated);
- v = 0;
-
- v = format (v, "limit %Ld, ", t->n_packets_limit);
+ int indent = format_get_indent (s);
- v = format (v, "rate %.2e pps, ", t->rate_packets_per_second);
-
- v = format (v, "size %d%c%d, ",
+ s = format (s, "limit %Ld, ", t->n_packets_limit);
+ s = format (s, "rate %.2e pps, ", t->rate_packets_per_second);
+ s = format (s, "size %d%c%d, ",
t->min_packet_bytes,
t->packet_size_edit_type == PG_EDIT_RANDOM ? '+' : '-',
t->max_packet_bytes);
+ s = format (s, "buffer-size %d, ", t->buffer_bytes);
+ s = format (s, "worker %d, ", t->worker_index);
- v = format (v, "buffer-size %d, ", t->buffer_bytes);
-
- v = format (v, "worker %d, ", t->worker_index);
-
- if (v)
+ if (verbose)
+ {
+ pg_edit_group_t *g;
+ /* *INDENT-OFF* */
+ vec_foreach (g, t->edit_groups)
{
- s = format (s, " %v", v);
- vec_free (v);
+ s = format (s, "\n%U%U", format_white_space, indent, format_pg_edit_group, g);
+ }
+ /* *INDENT-ON* */
}
return s;
@@ -190,6 +216,15 @@ show_streams (vlib_main_t * vm,
{
pg_main_t *pg = &pg_main;
pg_stream_t *s;
+ int verbose = 0;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "verbose"))
+ verbose = 1;
+ else
+ break;
+ }
if (pool_elts (pg->streams) == 0)
{
@@ -197,10 +232,10 @@ show_streams (vlib_main_t * vm,
goto done;
}
- vlib_cli_output (vm, "%U", format_pg_stream, 0);
+ vlib_cli_output (vm, "%U", format_pg_stream, 0, 0);
/* *INDENT-OFF* */
pool_foreach (s, pg->streams, ({
- vlib_cli_output (vm, "%U", format_pg_stream, s);
+ vlib_cli_output (vm, "%U", format_pg_stream, s, verbose);
}));
/* *INDENT-ON* */
@@ -210,8 +245,8 @@ done:
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (show_streams_cli, static) = {
- .path = "show packet-generator",
- .short_help = "Show packet generator streams",
+ .path = "show packet-generator ",
+ .short_help = "show packet-generator [verbose]",
.function = show_streams,
};
/* *INDENT-ON* */
@@ -277,10 +312,11 @@ validate_stream (pg_stream_t * s)
if (s->max_packet_bytes < s->min_packet_bytes)
return clib_error_create ("max-size < min-size");
- if (s->buffer_bytes >= 4096 || s->buffer_bytes == 0)
- return
- clib_error_create ("buffer-size must be positive and < 4096, given %d",
- s->buffer_bytes);
+ u32 hdr_size = pg_edit_group_n_bytes (s, 0);
+ if (s->min_packet_bytes < hdr_size)
+ return clib_error_create ("min-size < total header size %d", hdr_size);
+ if (s->buffer_bytes == 0)
+ return clib_error_create ("buffer-size must be positive");
if (s->rate_packets_per_second < 0)
return clib_error_create ("negative rate");
@@ -362,10 +398,6 @@ new_stream (vlib_main_t * vm,
}
}
- error = validate_stream (&s);
- if (error)
- return error;
-
if (!sub_input_given && !pcap_file_name)
{
error = clib_error_create ("no packet data given");
@@ -419,6 +451,10 @@ new_stream (vlib_main_t * vm,
}
}
+ error = validate_stream (&s);
+ if (error)
+ return error;
+
pg_stream_add (pg, &s);
return 0;
@@ -501,7 +537,10 @@ change_stream_parameters (vlib_main_t * vm,
error = validate_stream (&s_new);
if (!error)
- s[0] = s_new;
+ {
+ s[0] = s_new;
+ pg_stream_change (pg, s);
+ }
return error;
}
diff --git a/src/vnet/pg/edit.c b/src/vnet/pg/edit.c
index 8d1437e96bc..a0aab1fb566 100644
--- a/src/vnet/pg/edit.c
+++ b/src/vnet/pg/edit.c
@@ -167,7 +167,7 @@ unformat_pg_payload (unformat_input_t * input, va_list * args)
for (i = 0; i < len; i++)
v[i] = i % ilen;
- e = pg_create_edit_group (s, sizeof (e[0]), vec_len (v), 0);
+ e = pg_create_edit_group (s, sizeof (e[0]), 0, 0);
e->type = PG_EDIT_FIXED;
e->n_bits = vec_len (v) * BITS (v[0]);
diff --git a/src/vnet/pg/pg.h b/src/vnet/pg/pg.h
index 16463c2a8c5..bc3b03b7670 100644
--- a/src/vnet/pg/pg.h
+++ b/src/vnet/pg/pg.h
@@ -345,6 +345,7 @@ vlib_node_function_t pg_input, pg_output;
/* Stream add/delete. */
void pg_stream_del (pg_main_t * pg, uword index);
void pg_stream_add (pg_main_t * pg, pg_stream_t * s_init);
+void pg_stream_change (pg_main_t * pg, pg_stream_t * s);
/* Enable/disable stream. */
void pg_stream_enable_disable (pg_main_t * pg, pg_stream_t * s,
diff --git a/src/vnet/pg/stream.c b/src/vnet/pg/stream.c
index ddd15d66406..c91cacafe57 100644
--- a/src/vnet/pg/stream.c
+++ b/src/vnet/pg/stream.c
@@ -483,6 +483,31 @@ pg_stream_del (pg_main_t * pg, uword index)
pool_put (pg->streams, s);
}
+void
+pg_stream_change (pg_main_t * pg, pg_stream_t * s)
+{
+ /* Determine packet size. */
+ switch (s->packet_size_edit_type)
+ {
+ case PG_EDIT_INCREMENT:
+ case PG_EDIT_RANDOM:
+ if (s->min_packet_bytes == s->max_packet_bytes)
+ s->packet_size_edit_type = PG_EDIT_FIXED;
+ case PG_EDIT_FIXED:
+ break;
+
+ default:
+ /* Get packet size from fixed edits. */
+ s->packet_size_edit_type = PG_EDIT_FIXED;
+ if (!s->replay_packet_templates)
+ s->min_packet_bytes = s->max_packet_bytes =
+ vec_len (s->fixed_packet_data);
+ break;
+ }
+
+ s->last_increment_packet_size = s->min_packet_bytes;
+}
+
/*
* fd.io coding-style-patch-verification: ON